踩坑记录:uni.navigateTo携带参数(网址)跳转页面

uni.navigateTo携带参数(网址)跳转页面

问题:
传递参数(http://lt.sapxw.com/H5ErWeiMa/indexH5.aspx?id=290949&ckdh=637695418429358201)给intoInventoryRelativeDetail.vue页面,但是值实际传递了(http://lt.sapxw.com/H5ErWeiMa/indexH5.aspx)并报这个警告[sitemap 索引情况提示] 根据 sitemap 的默认规则,当前页面 [pagesBtnDetail/intoInventoryRelativeDetail/intoInventoryRelativeDetail?url=http%3A%2F%2Flt.sapxw.com%2FH5ErWeiMa%2FindexH5.aspx] 将被索引
在这里插入图片描述

解决办法:
使用encodeURIComponent() 函数和decodeURIComponent() 函数
encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。
decodeURIComponent() 函数对 URI 组件进行解码。完美解决!

scanURL(e) {
				if (e == '') {
					this.showToast('请扫描二维码!')
					return false
				}
				// http://lt.sapxw.com/H5ErWeiMa/indexH5.aspx?id=290949&ckdh=637695418429358201
				let url = encodeURIComponent(e);
				uni.navigateTo({
					url: `/pagesBtnDetail/intoInventoryRelativeDetail/intoInventoryRelativeDetail?url=${url}`
				})
			},

intoInventoryRelativeDetail.vue

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

<script>
	export default {
		data() {
			return {
				url: 'http://lt.sapxw.com/H5ErWeiMa/indexH5.aspx?id=290949&ckdh=637695418429358201',
			}
		},
		onLoad(e) {
			// 获取传递过来的链接
			let url = decodeURIComponent(e.url);
			console.log(url)
			this.url = url
		},
		methods: {

		}
	}
</script>

<style>

</style>

完美解决!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值