5***@qq.com
5***@qq.com
  • 发布:2019-12-23 15:58
  • 更新:2021-01-29 11:08
  • 阅读:3569

用uniapp开发的小程序嵌入的webview,webview中的网页使用vue开发,怎么跳回小程序啊

分类:uni-app

webview中的网页也是使用uniapp或者vue开发,现在js引进来了,但是js中的uni没有postMessage和getEnv方法

document.addEventListener('UniAppJSBridgeReady', function() {
document.querySelector('.btn-list').addEventListener('click', function(evt) {
var target = evt.target;
if (target.tagName === 'BUTTON') {
var action = target.getAttribute('data-action');
if(action === 'navigateTo') {
uni.navigateTo({
url: '/pages/component/button/button'
});
}
}
});
});

这块代码应该在vue或者uniapp中如何实现呢

2019-12-23 15:58 负责人:无 分享
已邀请:
饭团呀

饭团呀 - 饭团呀

我的web-view里面的网站是vue开发的。你在入口的index.html引入了js对吧, 然后直接在vue的单文件的方法里面就可以用了呀 直接用 uni.getEnv(function (res) {
console.log("当前环境:" + JSON.stringify(res));
});
是可以识别到uni对象的

该问题目前已经被锁定, 无法添加新回复