小编Ami*_*itz的帖子

Nativescript Webview和android后退按钮

我在nativescript中制作了一个仅包含webview的页面。这是我的代码:

<Page xmlns="http://www.nativescript.org/tns.xsd" actionBarHidden="true">

    <WebView src="http://example.com/" />

</Page>
Run Code Online (Sandbox Code Playgroud)

这是JS:

import * as webViewModule from "tns-core-modules/ui/web-view";

let webView = new webViewModule.WebView();

webView.on(webViewModule.WebView.loadFinishedEvent, function (args: webViewModule.LoadEventData) {
    let message;
    if (!args.error) {
        message = "WebView finished loading " + args.url;
    }
    else {
        message = "Error loading " + args.url + ": " + args.error;
    }

});
webView.src = "http://example.com/";
Run Code Online (Sandbox Code Playgroud)

一切正常,直到我按下android back按钮。然后,在导航到Webview的最后一页的内部,该应用程序刚刚存在。当我从应用程序菜单再次打开它(返回到最小化的应用程序)时,它将重新加载Webview内容,而不保存其状态。

帮助将不胜感激。

javascript android webview typescript nativescript

4
推荐指数
1
解决办法
1095
查看次数

标签 统计

android ×1

javascript ×1

nativescript ×1

typescript ×1

webview ×1