Vue 兄弟或父子組件傳值的一種方法,通過Vue的$emit發送事件,$on接收事件

通過Vue的$emit發送自定義事件,在需要使用的組件中接收 $emit $on (0)創建文件 eventBus.js   import Vue from 'vue' const eventBus = new Vue() export { eventBus } (1) 組件一中,在事件中觸發 eventBus.$emit('buy-number',this.inputNum)      //示
相關文章
相關標籤/搜索