小白菜QaQ
小白菜QaQ
  • 发布:2023-09-07 19:24
  • 更新:2023-09-07 19:24
  • 阅读:79

webview plus.webview.create 创建的修改 headers 未能生效

分类:HBuilderX
let url = this.qr_code_url;  
            const wv = plus.webview.create("", "custom-webview", {  
                additionalHttpHeaders: {  
                    'User-Agent': 'MicroMessenger',  
                }, //JSON类型,窗口加载页面时额外添加的HTTP请求头数据,内容按照http协议写.   
                plusrequire: "none",     
                'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突    
                top: uni.getSystemInfoSync().statusBarHeight +  
                    44,   
                height: this.vuex_screenHeight - (uni.getSystemInfoSync().statusBarHeight + 44),   
            })  
            wv.loadURL(url)  

            const currentWebview = this.$scope  
                .$getAppWebview();  
            currentWebview.append(wv);   
            const self = this;  
            this.wv = wv  
            wv.addEventListener('loaded', e => {  
                wv.canBack(e => {  
                    self.canBack = e.canBack  
                    currentWebview.setTitleNViewButtonStyle(0, {  
                        color: e.canBack ? '#000' : '#fff',  
                    });  
                })  
            })
2023-09-07 19:24 负责人:DCloud_App_Array 分享
已邀请:

要回复问题请先登录注册