zhuan888
zhuan888
  • 发布:2019-10-31 13:38
  • 更新:2020-11-18 15:59
  • 阅读:1566

overrideUrlLoading里的match在同一个页面如何匹配多个网址?

分类:uni-app

wv.overrideUrlLoading({mode:'reject',match:'tbopen://.*'}, function(e){
console.log('reject url: '+e.url);
});
overrideUrlLoading里的match在同一个页面如何才能匹配多个网址?文档里说多次调用overrideUrlLoading时仅以最后一次调用设置的参数值生效。

2019-10-31 13:38 负责人:无 分享
已邀请:
zhuan888

zhuan888 (作者)

完整的代码:

<template>
<view>
</view>
</template>
<script>
var wv;//计划创建的webview
export default {
onLoad() {
// #ifdef APP-PLUS
wv = plus.webview.create("","custom-webview",{
plusrequire:"none",
'uni-app': 'none',
top:uni.getSystemInfoSync().statusBarHeight+44
})
wv.loadURL("https://s.click.taobao.com/VP3zCxv")
var currentWebview = this.$mp.page.$getAppWebview()
currentWebview.append(wv);
wv.overrideUrlLoading({mode:'reject',match:'tbopen://.*'}, function(e){
console.log('reject url: '+e.url);
});
setTimeout(function() {
//console.log(wv.getStyle())
//wv.evalJS('alert("测试弹窗");');

    }, 1000);  
    // #endif  
}  

};
</script>

1***@qq.com

1***@qq.com

您好,请问这个问题解决了吗

来根十渠

来根十渠

正则
match: (String 类型 )区配是否需要处理的URL请求
支持正则表达式,默认值为对所有URL地址生效(相当于正则表达式“.*”)。 如果mode值为"allow"则允许区配的URL请求跳转,mode值为"reject"则拦截区配的URL请求。

  • c***@163.com

    到底是 string 里写正则,还是直接正则啊

    2022-08-24 18:26

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