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
| }
|
|