android - NativeScript loadStarted WebView 事件不会在 Android 上触发
问题描述
我在 NativeScript/Angular 中使用带有 loadStarted 和 loadFinished 事件的 Webview。在我的 iPhone (tns run ios) 上,这两个事件都被触发了。在我的 Android 手机(tns run android)上,未触发 loadStarted 事件,导致微调器发生故障。看起来只有与 tel:、mailto: 和 loc: 的链接触发 loadStarted 事件。希望有人可以帮忙。
XML:
<ActionBar #webviewActionbar title="Facilitor" flat="true">
<ActionItem (tap)="onQrScanTap()" ios.position="right" ios.systemIcon="15" android.systemIcon="ic_menu_camera">
</ActionItem>
</ActionBar>
<GridLayout rows="*">
<WebView row="0" #loginView (loaded)="webviewLoaded($event);" (loadStarted)="webviewTrigger($event)" (loadFinished)="onLoadFinished($event)" (doubleTap)="onDoubleTap($event)" (swipe)="onSwipe($event)" [src]="webViewSrc" ></WebView>
<TextField row="0" [(ngModel)]="registerModel.push_action" #pushActionModel="ngModel" autocorrect="false"
autocapitalizationType="none" [visibility]="'collapse'" (textChange)="navigateToAction()"></TextField>
<ActivityIndicator (loaded)="onSpinnerLoaded($event)" rowSpan="2" [busy]="isBusy" (busyChange)="onBusyChanged($event)" width="100" height="100"></ActivityIndicator>
</GridLayout>
打字稿:
private onLoadFinished(args: any) {
console.log("== onLoadFinished ==");
this.isBusy = false;
}
private webviewTrigger(args: any) {
console.log("== webviewTrigger ==");
var webView: WebView = <WebView>args.object;
console.log(webView);
// get location
if (args.url.startsWith('loc:')) {
let arr = args.url.split(":");
this.registerModel.push_action = this.registrationService.composeUrl() + arr[1] + "?longitude=" + this.lastLocation.longitude + "&latitude=" + this.lastLocation.latitude;
this.navigateToAction();
webView.reload();
return;
// handle mailto: and tel:
} else if (args.url.startsWith('mailto:') || args.url.startsWith('tel:')) {
utils.openUrl(args.url);
webView.reload();
return;
}
// start spinner
this.isBusy = true;
}
点击一些链接后的终端日志:
JS: == onNavigatingTo ==
chromium: [INFO:library_loader_hooks.cc(51)] Chromium logging enabled: level = 0, default verbosity = 0
JS: == webviewLoaded ==
JS: WebView(44)
JS: == setHTTPHeader ==
JS: == onSpinnerLoaded ==
JS: == onNavigatedTo ==
JS: == webviewTrigger ==
JS: WebView(44)
JS: indicator.busy changed to: true
JS: ===Location===
JS: == onLoadFinished ==
JS: indicator.busy changed to: false
JS: == onLoadFinished ==
JS: == onLoadFinished ==
JS: == onLoadFinished ==
解决方案
推荐阅读
- python - 在 Python 中的 format() 中应该如何传递变量?
- jestjs - 为什么不需要开玩笑?
- javascript - 通过jquery(或javascript)将动态添加的元素永久保存到视图(或项目)asp.net-mvc
- html - 如何并排创建两个 HTML 按钮
- mule - 在 Dataweave 转型方面需要帮助
- swift - 插入时 Swift 4 + SQLite
- asp.net - 我们可以为 IIS 7.5 中的两个应用程序使用相同的域吗?
- javascript - AngularFire2 更新创建新文档字段而不是更新字段
- python - 两个大型数据集的最快迭代合并
- python - 按下按钮时在 Python tkinter 条目中获取输入