nativescript-webview-interface事件调用返回给应用程序时出现问题-将纯Nativescript 5.x项目迁移到Nativescript 6

问题描述 投票:1回答:1

使用nativescript-webview-interface并将事件注册到webview。事件已触发应用程序,并且运行正常。但是在nativescript 6中,相同的代码无法正常工作。

var webViewInterfaceModule = require('nativescript-webview-interface');

exports.onWebViewLoaded = function(args){

var webview = args.object;

oWebViewInterface = new webViewInterfaceModule.WebViewInterface(webview, buildSrc()); 

//构建源返回html字符串

webview.on(webViewModule.WebView.loadFinishedEvent, (args) => {
    //do something specific to app
});
oWebViewInterface.on("watchInc", (data) => {
      console.log("event watchInc - want to do something app specific"); 
      //not receiving this event
});

oWebViewInterface.on("watchEnd", (data) => {
    console.log("event watchEnd - want to do something app specific");
    //not receiving this event
}, 200); // Timeout needed as loading event is fired when nothing ready...

}

webview nativescript migrate
1个回答
0
投票

感谢manoj。已移至nativescript-webview-ext插件,并且webview和javascript之间的通信正常。

© www.soinside.com 2019 - 2024. All rights reserved.