每日一篇(10)--vue关于父组件给子组件传值

在vue中 父组件给子组件传值 可以用到props属性进行传值。
今天就给大家讲讲props的使用方法:
父页面:father.vue

<template>
<children :mssage="msg"></children>
</template>

<script>
improt children form '../../children.vue';
export default {
	compontent:{
			children
	},
	data(){
		return{
			msg:'我是msg的值'
		}
	}
}
</script>

子页面:children.vue

<template>
	<div>{{mssage}}</div>
</template>
export default {
	props:{
		type:String,
		required:true
	}
}

至此,由父页面的值 就这样传过来了。

请注意打赏和关注哟:
在这里插入图片描述
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章