
父组件页面 ----- list.vue:
<template>
<div class="list">
我是父组件页面
<!--3、 使用子组件 -->
<EditList :parentVal="msg"/>
</div>
</template>
<script>
// 1、引入子组件
import EditList from '@/components/EditList'
export default {
name: 'List',
data () {
return {
msg: '我是来自父组件中的值'
}
},
components:{
//2、 注册子组件
EditList
}
}
</script>
子组件页面-----EditeList.vue:
<template>
<div class="editList">
<span style="color:red">子组件接收到父组件中传递的值是:</span>
{{parentVal}}
</div>
</template>
<script>
export default {
name: 'EditList',
props:{
parentVal:{
type:String
}
}
}
</script>
489

被折叠的 条评论
为什么被折叠?



