liyameng
liyameng
  • 发布:2020-12-24 17:23
  • 更新:2020-12-24 17:37
  • 阅读:938

请教:plus.webview.create创建的webview如何注入js

分类:uni-app
onLoad(){  
    wv = plus.webview.create('', 'custom-webview', {  
                            plusrequire: 'none', //禁止远程网页使用plus的API  
                            'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突  
                            top: uni.getSystemInfoSync().statusBarHeight + 44 //放置在titleNView下方。  
                        });  
                        wv.loadURL(this.url);  
                        var currentWebview = this.$scope.$getAppWebview();   
                        currentWebview.append(wv);  

}  
onReady() {  
            // #ifdef APP-PLUS  
                var currentWebview = this.$scope.$getAppWebview().children()[0];  
                //监听注入的js  
                currentWebview.addEventListener("loaded", function() {  
                    currentWebview.evalJS(  
                        "document.getElementById('header-wrap').style.display='none';"  
                    );  
                });  
            // #endif  
        },
2020-12-24 17:23 负责人:无 分享
已邀请:
DCMarvel

DCMarvel

wv.evalJS( "document.getElementById('header-wrap').style.display='none';" )

  • liyameng (作者)

    已经解决了,谢谢

    2020-12-24 18:05

该问题目前已经被锁定, 无法添加新回复