2.1 index.html
android调用js代码
android调用js代码并传递参数
JS调用android代码
JS调用android代码并传递参数
2.2 页面路径
将index.html页面放到如下路径下
AndroidWebView\app\src\main\assets\www\index.html
WebViewManager根据传入的文件名(index)获取url路径
object WebViewManager {
fun getWebUrl(name: String): String {
return “file:///android_asset/www/${name}.html”
}
}
3.1 页面中添加WebView
<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-