Lazy load pages random error:ERROR Error: Uncaught (in promise): invalid link:

后端 未结 12 1609
情书的邮戳
情书的邮戳 2021-01-01 14:35

I run into the following error every now and then.

ERROR Error: Uncaught (in promise): invalid link:MenuPage
    at d (polyfills.js:3)
    at l (polyfills.j         


        
相关标签:
12条回答
  • 2021-01-01 14:51

    Restart your server and you will be fine.

    0 讨论(0)
  • 2021-01-01 14:56

    I had a similar issue. Solved it by changing the "@ionic/app-scripts" to version "2.1.3" under devDependencies.

    "devDependencies": {
    "@angular/tsc-wrapped": "^4.4.6",
    "@ionic/app-scripts": "2.1.3",
    "typescript": "2.4.0" }
    
    0 讨论(0)
  • 2021-01-01 14:57

    Same thing happens to me sometimes. Likewise I was not able to determine where the error comes from, as it happens only rarely. Looks like a bug with the app scripts, as stopping and starting "ionic serve" seems to solve the issue.

    0 讨论(0)
  • 2021-01-01 14:58

    If you want lazy loading of components :

    Just add @IonicPage() decorator above the @Component decorator imported from 'ionic-angular' and restart your server after saving your work

    Example:

    ....
    import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
    ....
    
    @IonicPage()
    @Component({
    templateUrl : '',
    })
    export class XYZ{
       ........
    }
    

    Make sure you do not added the same page in app.module.ts file neither in declarations array nor in imports array.

    0 讨论(0)
  • 2021-01-01 14:59

    According to your error, it looks like you are trying to use the class name MenuPage as a deep link. this.navCtrl.push('MenuPage');

    ERROR Error: Uncaught (in promise): invalid link:MenuPage
    

    In your case, you declared the deep link as "menu". So you should use:

    this.navCtrl.push('menu');
    

    Or if you want, keep using the class, but without quotes: this.navCtrl.push(MenuPage);

    0 讨论(0)
  • 2021-01-01 15:00

    In MenuPage.ts : add this over the class MenuPage:

    @IonicPage(
    {
      name: 'tabs-page'
    })
    

    In app.components.ts

    rootPage: string = 'tabs-page';
    

    Please try it!

    0 讨论(0)
提交回复
热议问题