2016-03-24 147 views
3

我正在使用rootPage設置爲AuthPage的Ionic 2項目。後來,我創建了另一個名爲SplashPage的頁面(通過控制檯),但是當我將rootPage設置爲SplashPage時,出現錯誤Uncaught Error: Cannot find module "./pages/splash/splash"(app.bundle.js:3188)。有什麼問題的線索?未捕獲的錯誤:找不到模塊 - 離子2

app.ts

import {App, IonicApp, Platform} from 'ionic-angular'; 
import {ListPage} from './pages/list/list'; 
import {WishListPage} from './pages/wishlist/wishlist'; 
import {AuthPage} from './pages/auth/auth'; 
import {SplashPage} from './pages/splash/splash'; 

@App({ 
    templateUrl: 'build/app.html', 
    config: {}, // http://ionicframework.com/docs/v2/api/config/Config/ 
    providers: [UserService] 
}) 
class MyApp { 
    rootPage: any = SplashPage; 
    pages: Array<{title: string, component: any, user: string}>; 
    user: any; 
    constructor(private app: IonicApp, private platform: Platform, 
       private userService: UserService) { 
     this.initializeApp(); 
     this.user = userService; 

     // used for an example of ngFor and navigation 
     this.pages = [ 

      // No need to include this since the user shouldn't see 
      // the login page again until their session/token expires 
      //{ title: 'Login', component: AuthPage }, 

      // Since we don't need to fear our user manually navigating 
      // via url, why not manage naviagtion permissions with simple 
      // template conditionals `*ngIf` 
      { title: 'Wishlist', component: WishListPage, user: "shopper"}, // SHOPPER 
      { title: 'Current Orders', component: ListPage, user: "shopper" }, // SHOPPER 
      { title: 'Orders', component: ListPage, user: "boxer" }, // BOXER 
      { title: 'Profile', component: ProfilePage, user:"both" } // BOTH 
     ]; 

    } 

splash.ts

import {OnInit} from 'angular2/core'; 
import {NgIf} from 'angular2/common'; 
import {Page, NavController} from 'ionic-angular'; 

// @PAGES 
import {AuthPage} from '../auth/auth'; 

@Page({ 
    templateUrl: 'build/pages/splash/splash.html', 
    directives: [NgIf], 
    providers: [] 
}) 

export class SplashPage { 
    constructor() { console.log("@AuthPage: __init__"); } 
} 
+0

你找到了嗎?同樣的錯誤在這裏,謝謝 –

+0

@AlejandroLora尚未:/ –

+0

它可能是無用的,但嘗試'@Component'裝飾器,而不是'@Page'裝飾器,讓我們知道.. –

回答

-2

它看起來像app.ts你調用類spalsh但實際的類名SplashPage

所以嘗試,重命名SplashPageSplash in#splash.ts

+0

我懷疑這是問題所在。否則,我不得不將AuthPage類重新命名爲Auth,並將WishListPage重命名爲WishList(兩者都工作正常)。順便說一句,SplashPage是通過命令「離子g頁面飛濺」自動創建的 –

相關問題