摘要: 1.新建一个eventBus.js import Vue from 'vue'export default new Vue() 2.brother1.vue(发送方) import引入bus import bus from './eventBus' 自定义一个emit事件 bus.$emit('sh 阅读全文
posted @ 2021-08-30 18:41 ajaXJson 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 1.在父组件import子组件 2.挂载 3.在占位符中v-bind传入数据 4.子组件export default中props引入值 <!-- 简单数据类型message传值时复制的是对象,复杂数据类型userinfo引用的是数据地址 --> 父App.vue <template> <div> < 阅读全文
posted @ 2021-08-30 18:40 ajaXJson 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1.子组件view 子组件定义了一个click事件add点击来发送count值,并设置emit触发自定义事件numchange <template> <div> <button @click="add()">+1</button> </div></template><script>export de 阅读全文
posted @ 2021-08-30 18:40 ajaXJson 阅读(54) 评论(0) 推荐(0) 编辑