我正在使用 Deeplinks 和 ionic 3,但我创建的 url 不起作用。
这是网址:https://lucky.com/prd/rm74fEgBB2frzhagYcov https://lucky.com/prd/rm74fEgBB2frzhagYcov
这是我的代码:
this.deepLinks.route({
'/prd/:id': ProductDetailsPage,
'/rcm/:id': RecommendationDetailsPage
})
.subscribe((match) => {
console.log(match);
}, (nomatch) => {
console.log(nomatch);
});
他没有进入订阅功能,也没有进入匹配或不匹配
我的问题是什么?
请检查这个
import {Component, ViewChild} from '@angular/core';
import {Platform, Nav} from 'ionic-angular';
import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';
import {Deeplinks} from '@ionic-native/deeplinks';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage: string = 'DashboardPage';
@ViewChild(Nav) nav: Nav;
constructor(public platform: Platform,
statusBar: StatusBar,
splashScreen: SplashScreen,
private deeplinks: Deeplinks) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
if (platform.is('cordova')) {
this.deeplinks.routeWithNavController(this.nav, {
'/event/:year/:month/:eventItem/:title': 'ScheduleDetails',
'/email/verify/': 'Login',
'/password/reset/:token': 'ChangePassword',
'/prd/:id': 'ProductDetailsPage',
'/rcm/:id': 'RecommendationDetailsPage'
}).subscribe((match) => {
// console.log('success' + JSON.stringify(match));
}, (noMatch) => {
// alert('error' + JSON.stringify(noMatch));
// console.log('error' + JSON.stringify(noMatch));
});
}
});
}
}
并且不要忘记在 app.module.ts 文件中添加提供程序作为深层链接
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)