APP往webview通过evalJS注入方法时
鸿蒙不支持this.$scope.$getAppWebview().children()[0] ,使用uni.createWebviewContext
//template
<web-view id="webviewId" src="xxxxxx"></web-view>
//javascript
// #ifdef APP-HARMONY
this.currentWebview = uni.createWebviewContext('webviewId', this);
// #endif
// #ifdef APP-PLUS
this.currentWebview = this.$scope.$getAppWebview().children()[0];
// #endif
let token = uni.getStorageSync('token');
let tenant = uni.getStorageSync('tenantCode');
// 准备要传递的数据
let dataToPass = JSON.stringify({
token: token
});
this.currentWebview.evalJS(`uniappReceiveData('${JSON.stringify({ token: token,tenant: tenant})}')`)
2 个评论
要回复文章请先登录或注册
1***@qq.com
Adlaw