webview不能随页面一起滚动吗?map组件可以滚动,webview为什么不能?需要设置什么属性吗?
各位有用过webview组件的吗?页面上有多个webview,需要跟随页面上下可滚动
![闪亮](https://img-cdn-tc.dcloud.net.cn/account/identicon/9d93ce722144817f8d82f9487cc5850b.png)
- 发布:2019-08-26 16:30
- 更新:2023-03-05 13:35
- 阅读:3083
最佳回复
![DCloud_iOS_XHY](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/000/95/97/91_avatar_mid.jpg?v=1635249454)
创建子webview时,style 中有 position 属性,决定添加到父webview后的布局 position: "static"
即表示跟随父滚动,具体请参考 5+Api 文档; https://www.dcloud.io/docs/api/zh_cn/webview.html#plus.webview.WebviewPosition
for(let i = 0; i < 6; i++) {
wv = plus.webview.create("","custom-webview",{
plusrequire:"none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
top:uni.upx2px(248) + uni.upx2px(248 + 50) * i, //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
height:uni.upx2px(248),//uni.getSystemInfoSync().windowHeight - uni.upx2px(148)
position: "static" // 跟随父 webview 滚动
})
wv.loadURL("https://www.baidu.com")
currentWebview.append(wv);//一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
}
![g***@163.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/8c3788c54f30970c3f8e8b0de41ac6eb.png)
g***@163.com - 小程序开发、app开发
<web-view :src="src" class="webview" allow="fullscreen" :webview-styles="webviewStyles" style="margin-top:87rpx;height:580rpx" :v-if='show'></web-view>
data() {
return {
src: '',
show:'true',
webviewStyles: {
width: '100%',
height: '300px',
top: '76px',
progress: 'true', // 禁用进度条
position: "static", // 跟随父滚动
},
}
},
44596296
没效果啊
webviewPage = plus.webview.create('', 'baiduid', {
top: (data.height + 190),
height: 200,
position: "static" // 跟随父 webview 滚动
});
that.updateMapFn();
webviewPage.show();
webviewPage.hide();
2020-08-20 09:51