创建并引入组件

最后更新于:2022-04-02 03:32:48

[TOC] ## 创建组件 `/src/components/HelloWorld.vue` ``` ``` ## 父组件向子组件通讯 `src/App.vue` ``` // 或者 ``` `/src/components/HelloWorld.vue` ``` export default { props: ['msgProps'], mounted(){ console.log(this.msgProps); } } ``` ## 子组件向父组件通讯 在子组件中 ``` //js godFather:function () { this.$emit('clickByFather',"这是传给父组件的信息); }, }, ``` 父组件 ``` //js methods: { msgFromChild:function (msg) { console.log(msg); } }, ```
';