Commit c450f425 by 胡悦

循环获取wv设置webview宽度

1 parent 859f0dcf
......@@ -290,7 +290,7 @@ export default {
const setWebviewStyle = () => {
//修改UA为PC端
// plus.navigator.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0')
setTimeout(() => {
const setWebviewStyleWithRetry = () => {
const currentWebview = this.$parent.$scope.$getAppWebview();
const wv = currentWebview.children()[1];
......@@ -301,10 +301,23 @@ export default {
height: '97%',
width: '92%'
});
return true; // 成功设置样式
} else {
this.jumpUrl = '';
return false; // 未找到wv
}
}, 100);
};
const retrySetWebviewStyle = () => {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
setTimeout(retrySetWebviewStyle, 100);
};
// 处理课程详情
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!