小白菜QaQ
小白菜QaQ
  • 发布:2023-09-07 14:10
  • 更新:2023-09-07 14:10
  • 阅读:148

plus.webview.create 。 跳转微信链接打不开 普通浏览器不支持微信

分类:HBuilderX
        let url = this.qr_code_url;  
            console.log(url, '---')  
            const wv = plus.webview.create("", "custom-webview", {  
                plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止    
                'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突    
                top: uni.getSystemInfoSync().statusBarHeight +  
                    44, //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值    
                height: this.vuex_screenHeight - (uni.getSystemInfoSync().statusBarHeight + 44),  
                // bottom: 120,  
            })  
            wv.loadURL(url)  
            const currentWebview = this.$scope  
                .$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()     
            currentWebview.append(wv); /  

//这样打开一般普通url可以直接打开,但是如果是微信浏览器的就会打不开
wv.addEventListener('loaded', e => {
// 获取Webview的WebviewObject对象
var webViewObject = this.wv.getWebviewObject();
// 修改请求头
webViewObject.overrideUrlLoading({ headers: 'UserAgent: MicroMessenger' });

                wv.canBack(e => {  
                    self.canBack = e.canBack  
                    currentWebview.setTitleNViewButtonStyle(0, {  
                        color: e.canBack ? '#000' : '#fff',  
                    });  
                })  
            })  

修改请求头貌似也不行 有大佬遇到过类似问题吗

2023-09-07 14:10 负责人:无 分享
已邀请:

要回复问题请先登录注册