1.引用:
①在需要使用的父组件中通过import
引入;
②在vue
的components
中注册;
③在父组件中直接引用,如:<bar></bar>
2.传值给子组件
①在父组件通过v-bind
传入一个值,如:<bar :title="title"></bar>
②在子组件中,通过props
接收,如:
3.传值给父组件——通过this.$emit
将方法和数据传递给父组件
①子组件:this.$emit('helloWorld') // 传值给父组件
②父组件:
作者:꧁执笔小白꧂