首页 > 解决方案 > 离子深度链接错误,离子 3 / Angular 5 应用程序

问题描述

离子深度链接错误,

错误:未捕获(承诺中):TypeError:Object(...) 不是函数 TypeError:Object(...) 不是 Deeplinks.route 中的函数(http://localhost:8100/build/vendor.js :94242:126 )

代码:

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private deeplinks: Deeplinks) {


platform.ready().then(() => {
  // Okay, so the platform is ready and our plugins are available.
  // Here you can do any higher level native things you might need.
  statusBar.styleDefault();
  splashScreen.hide();



  this.deeplinks.route({
      '/': {},
      '/reset-password/:Id': MmresetpasswordPage
    })
    .subscribe(match => {
      alert(JSON.stringify(match));
    }, nomatch => {
      alert(JSON.stringify(nomatch));

    });

});

标签: angularionic3

解决方案


安装深度链接的 v5:npm i -s @ionic-native/deeplinks@5

import in components 和modules 之类的:(import {Deeplinks} from '@ionic-native/deeplinks/ngx'/ngx在最后)

然后component.ts像这样声明:constructor(private deeplinks:Deeplinks){}

然后app.module.ts像这样提供:providers:[Deeplinks]


推荐阅读