JavaScript/vue.js/兄弟组件的值:修订间差异
来自康健生活
< JavaScript | vue.js
| 第25行: | 第25行: | ||
... | ... | ||
methods:{ | methods:{ | ||
allCountryMessage(){ | |||
EventBus.$on('allCountry',(message)=>{ | |||
console.log(message) | |||
}) | |||
} | |||
... | ... | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
2020年7月4日 (六) 03:54的最新版本
子传父,父传子
vuex
eventBus
eventBus.js
import Vue from 'vue'
export default new Vue()
AllCountry.vue
import EventBus from "@/router/eventBus";
...
methods:{
allCountryEvent() {
EventBus.$emit('allCountry', {
isCountry: this.isCountry,
isDepartment: this.isDepartment,
isCountryValue: this.isCountryValue,
isDepartmentValue: this.isDepartmentValue,
})
}
}
...
HoptialList.vue
import EventBus from "@/router/eventBus";
...
methods:{
allCountryMessage(){
EventBus.$on('allCountry',(message)=>{
console.log(message)
})
}
...
No categories