1.创建一个空的文件

2.在文件夹里放置web-view

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

3.在js里接收传递过来的链接

<script>
	export default {
		data() {
			return {
				url: \'\'
			};
		},
		onLoad(val) {
			this.url = decodeURIComponent(val.url) //解码网址
		},
	}
</script>

 4.在要跳转的页面里的标签添加点击方法

<view class="banner" @tap="tonewurl">
</view>

  5.定义点击方法

	// 跳转外部链接
			tonewurl() {
				let url = this.result.vr_link;//接收返回的数据
				let shopId = this.result.uniacid;
				let utoken = uni.getStorageSync(\'user\').utoken;
				let unionid = uni.getStorageSync(\'user\').unionid;
				if (!this.getUserStatus()) {
					return;
				}
				// 判断链接是否为空
				if (url == null) {
					return false;
				}
				// 判断链接是否为https
				let notS = url.split(\':\')[0];
				let a = notS.indexOf(\'s\') > -1;
				if (a == false) {
					return false;
				}
                              //条件编译
				//#ifdef MP-WEIXIN
				var typefrom = \'wechat\';
				//#endif
				//#ifdef MP-BAIDU
				var typefrom = \'baidu\';
				//#endif
				//#ifdef MP-ALIPAY
				var typefrom = \'ali\';
				//#endif
				//#ifdef APP-PLUS
				var typefrom = \'APP\';
				//#endif
                            //  链接拼接编码网址(同时用模板字符串放置所需要的数据)
				url = encodeURIComponent(url + `?typefrom=${typefrom}&utoken=${utoken}&unionid=${unionid}&shopid=${shopId}`);
				uni.navigateTo({
					url: \'../newurl/newurl?url=\' + url
				});
			},        

  

版权声明:本文为Glant原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/Glant/archive/2004/01/13/11217270.html