可以监听web的pagestart事件或者pagefinish事件来获取,示例代码如下: <template>
<!-- Only one root node is allowed in template. -->
<div class="container" id="ani">
<text class="title">Hello World</text>
<web id="webid" src="{{src}}" onpagestart="onPageStart" onpagefinish="pagefinish" style="width:100%;height:500px"></web>
</div>
</template>
<style>
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
</style>
<script>
module.exports = {
data: {
componentData: {},
test: '',
src: "https://www.baidu.com"
},
onInit() {
},
onPageStart(e) {
console.info('pagestart: ' + e.url)
},
pagefinish(e) {
console.info('pagefinish: ' + e.url)
}
}
</script> 第一次打开网页时获取的H5地址如下:
网页多次打开后获取的H5地址如下:
|