props传值,组件,父传子

97 阅读1分钟

父组件: 1、在data中定义好变量 2、引入子组件 3、在子组件标签中 :child='变量名'

子组件:

	name: 'Yule',						组件的名字
	props: {
		titles: {
			type: Array,				类型
			required: true				必传
            							默认
		}
	},
<template>
	<view>
		<view v-for="item in titles">{{item.name}}</view>
	</view>
</template>