组件绑定

一、props
1、静态绑定
   <com-a title="测试" @child="mymethod"></com-a>
2、动态绑定
   <com-a :title="title" @child="mymethod"></com-a>
3、子页面接收

props: ['title', 'likes', 'isPublished', 'commentIds', 'author']
props: {
  title: String,
  likes: Number,
  isPublished: Boolean,
  commentIds: Array,
  author: Object
}
 

二、emit(发射)
@自定义方法="父页面接收的方法"
1、v-on:boy_to_father="listentoBoy"同: @boy_to_father="listentoBoy"
2、boy_to_father:子页面方法,listentoBoy:父页面方法
3、listentoBoy:父页面方法通过参数传值
4、boy_to_father:子页面中的方法,通过this.$emit('boy_to_father',this.msg)进行赋值

猜你喜欢

转载自blog.csdn.net/wdfx100/article/details/86221235