问题描述
package.json,这是package.json 文件
{
"name": "deeplink","version": "0.0.1","author": "Ionic Framework","homepage": "https://ionicframework.com/","scripts": {
"ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
},"private": true,"dependencies": {
"@angular/common": "~11.2.0","@angular/core": "~11.2.0","@angular/forms": "~11.2.0","@angular/platform-browser": "~11.2.0","@angular/platform-browser-dynamic": "~11.2.0","@angular/router": "~11.2.0","@ionic-native/core": "^5.31.1","@ionic-native/deeplinks": "^5.31.1","@ionic/angular": "^5.5.2","rxjs": "~6.6.0","tslib": "^2.0.0","zone.js": "~0.10.2"
},"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.4","@angular/cli": "~11.2.4","@angular/compiler": "~11.2.0","@angular/compiler-cli": "~11.2.0","@angular/language-service": "~11.2.0","@ionic/angular-toolkit": "^3.1.1","@types/jasmine": "~3.6.0","@types/jasminewd2": "~2.0.3","@types/node": "^12.11.1","codelyzer": "^6.0.0","cordova-android": "^9.0.0","cordova-plugin-device": "^2.0.2","cordova-plugin-ionic-keyboard": "^2.2.0","cordova-plugin-ionic-webview": "^4.2.1","cordova-plugin-splashscreen": "^5.0.2","cordova-plugin-statusbar": "^2.4.2","cordova-plugin-whitelist": "^1.3.3","ionic-plugin-deeplinks": "^1.0.22","jasmine-core": "~3.6.0","jasmine-spec-reporter": "~5.0.0","karma": "~5.2.0","karma-chrome-launcher": "~3.1.0","karma-coverage": "~2.0.3","karma-coverage-istanbul-reporter": "~3.0.2","karma-jasmine": "~4.0.0","karma-jasmine-html-reporter": "^1.5.0","protractor": "~7.0.0","ts-node": "~8.3.0","tslint": "~6.1.0","typescript": "~4.0.2"
},"description": "An Ionic project","cordova": {
"plugins": {
"ionic-plugin-deeplinks": {
"URL_SCHEME": "abc","DEEPLINK_SCHEME": "https","DEEPLINK_HOST": "mytest.com","ANDROID_PATH_PREFIX": "/"
},"cordova-plugin-whitelist": {},"cordova-plugin-statusbar": {},"cordova-plugin-device": {},"cordova-plugin-splashscreen": {},"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},"cordova-plugin-ionic-keyboard": {}
},"platforms": [
"android"
]
}
}
import { Component,ViewChildren,QueryList,AfterViewInit,ngzone } from '@angular/core';
import { Deeplinks } from '@ionic-native/deeplinks/ngx';
import { PostsPage } from './posts/posts.page';
// import { Component,ngzone } from '@angular/core';
import { AlertController,IonRouterOutlet,Platform } from '@ionic/angular';
@Component({
selector: 'app-root',templateUrl: 'app.component.html',styleUrls: ['app.component.scss'],})
export class AppComponent {
constructor(
private deeplinks: Deeplinks,private zone: ngzone,private platform: Platform,) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(async () => {
this.setupDeeplinks();
});
}
setupDeeplinks() {
try {
this.deeplinks.route({
'/:slug': 'posts',}).subscribe(
match => {
// alert("match " + localStorage.getItem("accesstoken"));
// Run the navigation in the Angular zone
this.zone.run(() => {
alert("match " + JSON.stringify(match));
});
},nomatch => {
alert("error " + JSON.stringify(nomatch.$link));
// nomatch.$link - the full link data
}
);
} catch (e) {
alert(JSON.stringify(e));
}
}
}
我有上面的深层链接代码,但是当我点击像 https://mytest.com/4665465 这样的 url 时它不起作用,它打开了应用程序但路由不匹配它的转到 nomatch 块,我已经关注了这个视频对于这个https://www.youtube.com/watch?v=DG7TMredeUs&t=312s,请帮忙
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)