<template><h3>ComponentA</h3><ComponentB :title="title":age="age":names="names"/></template><script>import ComponentB from'./ComponentB.vue';exportdefault{data(){return{title:"测试",//age:20,//names:["Tom","Bob"]}},components:{
ComponentB
}}</script>
________________________________________________________________________________
<template><h3>ComponentB</h3><p>{{ title }}</p><p>{{ age }}</p><ul><li v-for="(name,index) of names":key="index">{{ name }}</li></ul></template><script>exportdefault{data(){return{}},props:{title:{type:[String,Number,Array,Object]},age:{type:Number,default:0},//数字和字符串可以直接default,但是如果是数组和对象,必须通过工厂函数返回默认值names:{type:Array,default(){return["xxx"]}}}}</script>