uniapp页面传参

路由传参

index.vue

<template>
	<view>
		<view class="mian">
			<view class="sideBar">
				<view class="item" v-for="(item,index) in from.data" :key="item.id" @click="active(index)"><text class="line" v-show="item.show"></text>{{item.name}}</view>
			</view>
			<view class="category">
				<view class="fresh-message" @click="toNivgter">
					<view class="fresh-img">
						<img src="https://mall.s.maizuo.com/86d8414272e50b4b9a7b185ac30dfc86.png?x-oss-process=image/resize,w_180">
					</view>
					<view class="fresh-name">
						金秋红蜜桃
					</view>
				</view>
			</view>
		</view>
		<Footer></Footer>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				from : {
					data : [
						{
							id: 0,
							name : "时令鲜果",
							show : true
						},
						{
							id : 1,
							name : "海鲜水产",
							show : false
						},
						{
							id : 2,
							name : "家禽蛋",
							show : false
						},
						{
							id : 3,
							name : "地方农产",
							show : false
						},
						{
							id : 4,
							name : "百果园公司",
							show : false
						},
						{
							id : 5,
							name : "农品茗茶",
							show : false
						},
						{
							id : 6,
							name : "五谷杂粮",
							show : false
						},
						{
							id : 7,
							name : "牛羊肉",
							show : false
						}
						]
				},
				num : 0
			}
		},
		methods: {
			active(index){
				this.from.data.forEach((item)=>{
					item.show=false;
				})
				this.from.data[index].show=true;
			},
			toNivgter(){
				let obj={title:"葛乐真帅气",message:"确实啊"};
				uni.navigateTo({
					url:"../target/target"
				})
			}
		}
		
	}
</script>

<style scoped>
	.mian{
		width: 100%;
		display: flex;
	}
	.sideBar{
		width: 30%;
		height: 1200rpx;
		background-color: #f4f4f4;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		padding: 10rpx 0 0 0 ;
	}
	.item{
		width: 100%;
		height: 100rpx;
		display: flex;
		box-sizing: border-box;
		padding: 0 10rpx;
		align-items: center;
		color: #333;
		font-size: 28rpx;
		position: relative;
	}
	.line{
		width: 3px;
		height: 100%;
		background-color: red;
		position: absolute;
		left: 0px;
		top: 0px;
		transition: all .5s;
	}
	.category{
		width: 70%;
		height: 1200rpx;
		overflow: hidden;
		overflow-y: auto;
		background-color: #fff;
		box-sizing: border-box;
		padding: 0 10px;
	}
	.fresh-message{
		width: 90px;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.fresh-img{
		width: 100%;
	}
	img{
		width: 100%;
	}
	.fresh-name{
		width: 100%;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
</style>

// target.vue
created(){
  //可以拿到我们传递过来的参数
	this.$route.query.id
}

同一页面下的兄弟传参

$emit 触发事件
$on 注册事件
$off 卸载事件
$once 注册单次事件

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值