$bus
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
:class="{ active: activeIndex === item.id }"
|
:class="{ active: activeIndex === item.id }"
|
||||||
v-for="item in tabList"
|
v-for="item in tabList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
|
@click="setActiveIndex(item.id)"
|
||||||
>
|
>
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
</div>
|
</div>
|
||||||
@ -26,7 +27,14 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {},
|
methods: {
|
||||||
|
setActiveIndex(id) {
|
||||||
|
if (this.activeIndex !== id) {
|
||||||
|
this.activeIndex = id;
|
||||||
|
this.$bus.emit("setActiveIndex", this.activeIndex);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,13 @@ export default {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {},
|
methods: {
|
||||||
|
receiveBUS() {
|
||||||
|
this.$bus.on("setActiveIndex", (val) => {
|
||||||
|
console.log("val===>", val);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user