尝试调用WebView,同时调用本地网页会给出错误
未捕获的类型错误:对象 ["某个对象"] 没有方法:"包含", 来源: file:///storage/sdcard0/MyDemo/js/fileName.js
它将给奇巧及以下错误。 它在奇巧之上正常工作。
它在下面的gradle设置下工作正常
compileSdkVersion 25
buildToolsVersion "25.0.2"
和依赖关系
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1
当前正在使用 Gradle 设置。
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
这是因为您在 js 文件中对字符串使用了includes
方法,最新的 JavaScript 版本 ECMAScript 6 和 android kitkat webview 不支持此版本。
您需要使用indexOf
而不是includes
var str = "Hello world, welcome to the universe.";
var n = str.includes("world");
# Replace above line of code and use indexOf.
var n = str.indexOf("world") > -1;