網站首頁 編程語言 正文
問題
? ? ? ? 有一個內嵌外部網頁的需求,而頁面內嵌進來出現跨域,從而進行一系列嘗試
解決思路
? ? ? ? 由于是H5開發,當時內嵌用的是iframe,想起移動端有一個webview,webview的權限比iframe的高,就想著用webview嘗試一下,但是發現最終瀏覽器把webview還是解析成為了iframe,于是自己寫了一個demo,在原生環境下運行測試了一下webview,發現并未出現跨域問題,于是想著那我像app殼子那樣用plus動態創建一個webview呢,應該不會被解析成iframe了把,測試過后,發現成功解決
解決代碼邏輯
mounted() {
if (window.plus) { // 判斷是否又plus
this.plusReady();
} else {
document.addEventListener('plusready', this.plusReady, false);
}
},
methods: {
plusReady() {
this.ws = plus.webview.currentWebview(); // 動態創建一個當前窗口
this.createWebview();
},
createWebview(){
// 創建webview this.src:地址 embed:id名稱
let embed = plus.webview.create(this.src, 'embed', {
top: '58px',
bottom: '0px',
position: 'dock'
});
this.embed = embed;
// 添加到當前窗口
this.ws.append(embed);
}
},
// 組件銷毀時清除,解決返回后,webview窗口未銷毀返回導致遮擋原頁面的問題
destroyed() {
// 從webview實例中移出
this.ws.remove(this.embed);
// 清除
this.embed.removeFromParent();
this.embed.close();
}
????????
原文鏈接:https://blog.csdn.net/qq_45689385/article/details/124177902
- 上一篇:VScode設置自定義背景
- 下一篇:react中的redux
相關推薦
- 2022-03-03 Module build failed: Error: Node Sass version 6.0.
- 2022-04-08 iOS實現簡單計算器功能_IOS
- 2022-08-25 詳解C語言中結構體的使用_C 語言
- 2022-08-11 GoFrame基于性能測試得知grpool使用場景_Golang
- 2022-10-28 Go語言開發保證并發安全實例詳解_Golang
- 2022-07-09 python?監控某個進程內存的情況問題_python
- 2022-12-10 Go?web中cookie值安全securecookie庫使用原理_Golang
- 2022-12-13 Android之rk3588?開發環境準備及問題解決方法_Android
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支