wu
2023-09-06 3eced65b14a858329fd2b7f4c8bc6c5d66710c78
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const state = {
  tags: []
}
 
const mutations = {
  addTag(state, tag) {
    if (!state.tags.includes(tag)) {
      state.tags.push(tag);
    }
  },
  removeTag(state, index) {
    state.tags.splice(index, 1);
  },
  removeAllTags(state) {
    state.tags = [];
  },
  switchTag(tag) {
    this.$emit('switchTag', tag);
    this.$router.push('/' + tag); // 添加这行代码以切换路由
  }
}
 
export default {
  namespaced: true,
  state,
  mutations
}