uni-app 跳转外部链接

A页面用uni.navigateTo跳转一个渲染外部链接的内部B页面

url是文件路径。要用encodeURIComponent编码。不然路径会不完整

//A页面

tapdetail: function(i) {
let	url='http://saas.juwoxing.com/order/newpage/share/article_share.html?id='+i+''
 url = encodeURIComponent(url)
	uni.navigateTo({
		url:'softwendetail/softwendetail?url='+url
	})
},

渲染外部要用web-view

记得接收到传过来的路径要用decodeURIComponent解码。实现跳转外部链接

//B页面
<template>
	<web-view :src="url" :progress="false"></web-view>
</template>

<script>
    export default {
        data() {
            return {
                url:'',
                title:''
            }
        },
        onLoad(op) {
			console.log(op.url)
            this.url = decodeURIComponent(op.url);
			console.log(this.url)
        },
		onReady(){//改变标题
            uni.setNavigationBarTitle({
                title:this.title
            })
        }
    }
</script>

猜你喜欢

转载自blog.csdn.net/weixin_44285250/article/details/115479522