【发布时间】:2020-10-02 05:22:15
【问题描述】:
I/chromium( 4243): [INFO:CONSOLE(34)] "Uncaught TypeError: JSReceiver.Disconnect is not a function", source: https://myUrl......
我正在使用带有 Flutter 的 webview,我想与 webview 中的函数 javascript 进行交互并将其发送到 flutter。换句话说,我想与 webview 断开连接。
在我的网络视图中我正在使用
<div class="menuopt" onclick="JSReceiver.Disconnect();">Logout</div>
到目前为止我在 Flutter 中所做的尝试:
WebView(
initialUrl:
'https://www.url/insert.html?token=$token&id_user=$id',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controler.complete(webViewController);
},
javascriptChannels: Set.from([
JavascriptChannel(
name: 'JSReceiver',
onMessageReceived: (JavascriptMessage message) {
Disconect(){
sharedPreferences.clear();
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (BuildContext context) => LoginPage()), (Route<dynamic> route) => false);
print("disconnect");
}}
)
]),
);
【问题讨论】:
-
您好,您使用的是哪个网页视图插件?您能否详细说明您的代码的行为以及期望的行为是什么?
-
他我正在使用 webview flutter "package:webview_flutter/webview_flutter.dart"。我希望我的功能将我转发到登录页面。但相反,这是我在我的 web 视图中单击注销按钮后得到的:I/chromium(4243): [INFO:CONSOLE(34)] "Uncaught TypeError: JSReceiver.Disconnect is not a function",来源:https:/ /
标签: api rest flutter dart webview