Skip to content

Instantly share code, notes, and snippets.

@yumi0629
Created April 2, 2019 02:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yumi0629/ac8505c469f6eaa8e600b85927f326fb to your computer and use it in GitHub Desktop.
Save yumi0629/ac8505c469f6eaa8e600b85927f326fb to your computer and use it in GitHub Desktop.
flutter_webview_js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Amaze UI 在线调试</title>
<link rel="stylesheet" href="http://cdn.amazeui.org/amazeui/2.5.0/css/amazeui.min.css"/>
</head>
<body>
<button onclick="callFlutter()">callFlutter</button>
<button onclick="callJS('hidden')">hide</button>
<p id="p1" style="visibility:hidden;">
Flutter 调用了 JS.
Flutter 调用了 JS.
Flutter 调用了 JS.
</p>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://cdn.amazeui.org/amazeui/2.5.0/js/amazeui.min.js"></script>
</body>
</html>
function callJS(message){
document.getElementById("p1").style.visibility = message;
}
function callFlutter(){
/*约定的url协议为:js://webview?arg1=111&arg2=222*/
document.location = "js://webview?arg1=111&args2=222";
// Toast.postMessage("JS调用了Flutter");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment