uniapp跳转外部链接

总体思路是用uni.navigateTo跳转一个渲染外部链接的内部页面

downLoad(item){
				let url = encodeURIComponent(item.url)
				uni.navigateTo({
					url:'./webView?url='+url
				})
			},

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

渲染外部要用web-view

webView.vue页面

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

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

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

  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值