我在两个vue组件中具有以下代码:
data() {
return {
overlay: false
};
},
created() {
EventBus.$on("toggleSidebar", status => (this.overlay = status));
}
如何在mixin中使用它?
这是我的mixin(toggle.js)
import EventBus from "@/eventBus";
const toggle = () => {
return {
data() {
return {
show: false
};
},
created() {
EventBus.$on("toggleSidebar", status => (this.show = status));
}
};
};
export default toggle;
但是我不能使用它
答案 0 :(得分:0)
import EventBus from "@/eventBus";
const toggle = {
data() {
return {
show: false
};
},
created() {
EventBus.$on("toggleSidebar", status => (this.show = status));
}
};
export default toggle;