【发布时间】:2018-02-26 08:05:36
【问题描述】:
我最近一直在使用 NativeScript 开发我的第一个 Web 应用程序,并且在过去的几天里一直停留在这个问题上。
该应用程序是基于 Nativescript 3.2 构建的,带有 angular
当用户单击按钮然后收听完成的加载事件时,我的应用程序使 web 视图可见。代码按预期工作,直到我尝试重定向到另一个页面。尽管应用程序崩溃了,但我不确定它是否进入了重定向循环。
webViewSetup() {
let webview: WebView = this.webView.nativeElement;
let navCount = 0;
webview.src = // Backend url
webview.on(WebView.loadFinishedEvent, function (args: LoadEventData) {
var res = args.url.substr(0,args.url.indexOf("?"));
if(res == // Success page url)
{
// Do something
if(navCount === 0 ){ // Crashes the application
this.routerExtension.navigate(["home"],{clearHistory: true});
}
}
}
Auth(){
this.isLoading = true;
this.webViewSetup();
}
我希望有人能够解释应用程序崩溃的原因,或者可能是重定向到下一页的更好方法。
【问题讨论】:
标签: angular typescript nativescript