uni-app注入说明
<h5>如果您的APP是通过uni-app开发,请使用以下方法注入所需要的js文件</h5>
<pre><code class="language-java">// 方法一
let currentWebview = this.$mp.page.$getAppWebview()
console.log(currentWebview)
setTimeout(() => {
this.wv = currentWebview.children()[0]
this.wv.appendJsFile('/static/jxwApp.js')
}, 1000)
// 方法二
var wv = plus.webview.create(this.url, "jxw", {});
wv.addEventListener("loaded", (function() {
//android 可写外面 ios的js注入必须在页面加载完成后
// 1s延迟保证对象load完成
setTimeout(() => {
// 确保提供的js文件路径正确,您可自行放置文件,确保这里填写的路径能够找到文件
wv.appendJsFile('/static/jxwApp.js')
console.log("注入js完成");
}, 1000);
}));
wv.show();
// 获取当前页面的webview对象
var currentWebview = this.$mp.page.$getAppWebview();
// 一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
currentWebView.append(wv); </code></pre>
<h5>js文件及demo下载:</h5>
<p><a href="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/b675fbd1403677da258f255f58bb5573" title="[uniapp.zip">uniapp.zip</a></p>