uniapp得自定义组件--组件传值

自定义组件

//子组件
<template>
	<view class="list">
		<view class="list_list" v-for="(item,key) in list" :key="key"
		//跳转路径
		 @click="Tip(item.path)">
			<image :src="item.imgUrl" mode=""></image>
			<text>{{item.title}}</text>
			<text class="iconfont icon-arrow-right list_text"></text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			};
		},
		//props接收父组件传递得数据
		props: {
			list: {
				type: Array,
				value: []
			}
		},
		methods: {
		//点击跳转到指定路径
			Tip(path) {
				uni.navigateTo({
					url: `${path}`
				})
			}
		}

	}
</script>

<style>
	.list_text {
		position: absolute;
		right: 10rpx;
		font-size: 24px;
	}

	.list {
		margin-top: 40rpx;
	}

	.list_list {
		display: flex;
		align-items: center;
		height: 100rpx;
		font-size: 30rpx;
		padding: 25rpx;
		box-sizing: border-box;
		border-top: 1rpx solid #ddd;
	}

	image {
		width: 45rpx;
		height: 45rpx;
		margin: 3%;
	}
</style>

//父组件
<template>
	<view>
		<!-- 四宫格 -->
		<fouerTable :fouerTable="fouerTable"></fouerTable>
		<!-- 列表 -->
		<list :list="list"></list>
	</view>
</template>

<script>
	import list from '../../components/list.vue'
	import fouerTable from "../../components/fourTable.vue";
	export default {
		components: {
			fouerTable,
			list
		},
		data() {
			return {
				fouerTable: [{
						iconUrl: require('../../static/image/member-icon1.png'),
						title: "待付款",
						path: "/components/money"
					},
					{
						iconUrl: require('../../static/image/member-icon2.png'),
						title: "待收货",
						path: "/components/Two"
					},
					{
						iconUrl: require('../../static/image/member-icon3.png'),
						title: "待评价",
						path: "/components/Three"
					},
					{
						iconUrl: require('../../static/image/member-icon4.png'),
						title: "全部订单",
						path: "/components/Four"
					}
				],
				list: [{
						imgUrl: require('../../static/image/member-menu1.png'),
						title: "收获地址",
						path: "/components/five"
					},
					{
						imgUrl: require('../../static/image/member-menu2.png'),
						title: "在线客服"
					},
					{
						imgUrl: require('../../static/image/member-menu3.png'),
						title: "邀请有礼"
					},
					{
						imgUrl: require('../../static/image/member-menu4.png'),
						title: "关于我们"
					}
				]
			};
		}
	}
</script>

<style>
	/* header */
	.header_logo {
		width: 100%;
		height: 70px;
		background-image: url(../../static/image/member-top.png);
		background-size: 100% 100%;
	}

	.header_nav {
		display: flex;
	}

	.header_left {
		flex: 1;
		font-size: 12px;
		color: #fff;
		height: 70rpx;
		padding: 20px 62px;
		box-sizing: border-box;
	}

	.header_bottom {
		margin-bottom: 6px;
	}

	.header_right {
		display: flex;
		justify-content: space-around;
		align-items: center;
		width: 25px;
		height: 70px;
	}

	.header_Image {
		width: 20px;
		height: 20px;
	}

	/* 退出 */
	.btn{
		width: 100%;
		padding: 30rpx;
		box-sizing: border-box;
		margin-top: 20rpx;
	}
</style>


效果展示
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值