1.很多情况我们想要在uniapp 的app端小程序端只用某些功能比如echrats,canvas,第三方插件等,当然了uniapp也有自带的但是还是无法满足我们的开发需求,那么webview来了,先看看官方文档https://uniapp.dcloud.net.cn/component/web-view.html#
1.注意事项
在uniapp使用webview嵌入自己的html需在\hybrid\html下面包括资源文件js等都需要放入同等该目录下
2.webvew默认全屏
比如我们想半屏嵌入我们的直播插件,等等虽然官方有fullscreen属性设置但是在app端仍有不支持
解决方案
onReady() {
// #ifdef APP-PLUS
var currentWebview = this.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
setTimeout(function() {
wv = currentWebview.children()[0]
this.wv = currentWebview.children()[0]
wv.setStyle({top:60,height:320})
}, 1000); //如果是页面初始化调用时,需要延时一下
// #endif
},
uniapp 和webview也可以互相通信,欢迎您下次再次观看