做一个自己的学习记录
<script>
import { computed, ref, watch } from 'vue'
import { useStore } from 'vuex'
export default {
name: 'player',
setup() {
// todo vue3 下获取 stor 数据
const store = useStore()
// 获取 state 中的 stateA
const stateA = computed(() => store.state.stateA )
// todo 触发 mutations
const goCommit = () => {
store.commit('goCommit', false)
}
// todo 触发 actions
const goDispatch = () => {
store.dispatch('goDispatch')
}
return { stateA , goCommit , goDispatch }
}
}
</script>