12-两种方式导航跳转和传参

导航页面

<template>
	<view>
		<view>导航跳转的学习</view>
		<navigator url="../detail/detail?id=80">跳转至详情页</navigator>
		<!-- 跳转到tabbar页面 需设置open-type="switchTab"-->
		<navigator url="../message/message" open-type="switchTab">跳转至信息页</navigator>
		<!-- 重定向跳转是没有返回箭头的 -->
		<navigator url="../detail/detail" open-type="redirect">跳转至详情页</navigator>
		<button @click="goDetail">跳转至详情页</button>
		<button @click="gomsg">跳转至信息页</button>
		<button @click="redirectgodetail">跳转至详情页并关闭当前页面</button>
	</view>
</template>

<script>
	export default{
		methods:{
			goDetail(){
				// 不会关闭其他页面 导航依然存在
				uni.navigateTo({
					url:"../detail/detail"
				})
			},
			gomsg(){
				// 会关闭其他非tabbar页面
				uni.switchTab({
					url:'../message/message'
				})
			},
			redirectgodetail(){
				// 关闭当前页面并跳转
				uni.redirectTo({
					url:"../detail/detail?op=90"
				})
			}
		}
	}
</script>

<style>
</style>

详情页接收参数

<script>
	export default{
		// options就是上一个页面传过来的参数
		onLoad(options) {
			console.log(options)
		}
	}
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值