父组件:
<propss :pos='persons'></propss>
//引入子组件
import propss from './props.vue';
data() { return{ inHot: true, n:0, x:1, keyWords:"", // 原始数据 persons:[ {id:1,name:'马冬梅',age:18,sex:"女"}, {id:2,name:"周冬雨",age:19,sex:"女"}, {id:3,name:"周杰伦",age:20,sex:"男"}, {id:4,name:"温兆伦",age:21,sex:"男"}, ], } }
子组件:
<template> <div id="props"> <h1>接收传值</h1> <ul> <li v-for="a,index in pos" :key="index">姓名:{{a.name}}年龄:{{a.age}}性别:{{a.sex}}</li> </ul> </div> </template> <script> export default {
//接收传过来的值 props:{ pos:{ type:Array, //类型 default:[] //默认值 } }, } </script>
标签:子父,name,age,sex,props,id,传值 From: https://www.cnblogs.com/0722tian/p/17144084.html