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
28
| <template></template>
|
| <script setup>
| import { useStore } from 'vuex';
|
| const store = useStore();
| // state必须带上.home
| const singleUavHome = computed(() => store.state.home.singleUavHome);
| // getters不需要带.home
| const test = computed(() => store.getters.test);
|
| onMounted(() => {
| // commit dispatch 不需要带.home
| store.commit('xxxx', '同步步修改啦');
| store.dispatch('xxxx', '异步修改啦');
| });
|
| watch(
| singleUavHome,
| (newValue, oldValue) => {
| console.log(newValue);
| },
| { immediate: true, deep: true }
| );
| </script>
|
|
| <style scoped lang="scss"></style>
|
|