我一直在测试 NativeScript 并遇到以下问题:
我在 app.component.ts 文件中声明了这些路由:
@RouteConfig([
{ path: "/Home", component: HomePage, name: "Home", useAsDefault: true },
{ path: "/Scan", component: ScanPage, name: "Scan"},
{ path: "/Webview", component: WebviewPage, name: "Webview"}
])
在我的 HomePage 组件中,我声明了以下方法:
export class HomePage {
constructor(private _router: Router) {}
public goToScanPage() {
this._router.navigate(["Scan"])
}
public goToWebviewPage() {
this._router.navigate(["Webview"])
}
}
现在,奇怪的是,当我在 android 或 ios 上加载应用程序并启动 goToScanPage() 方法时,它一切正常,我可以看到新页面,但是当我点击按钮启动 goToWebviewPage() 时,我得到一个空白页。据我所知,底层组件已加载,但视图为空白。当我将一个组件中的模板文件替换为另一个组件时,我可以在使用 goToScanPage() 时看到另一个视图,因此模板文件没有任何问题。我在这里做错了吗?