import { reactive, ref, toRefs, onMounted, getCurrentInstance, computed, watch } from ‘vue‘
import { useStore } from ‘vuex‘
// vuex
const store = useStore()
const changeTextName = () =>{
store.dispatch(‘commitTextName‘, ‘修改了哦!‘)
}
console.log(‘store‘, store.state.textName)
watch(() => store.state.textName, (val, old) => {
console.log(val, old)
})
// vuex deep 深度监听,第三个参数加上{deep:true}
watch(
() => store.state.textName,
(val, old) => {
console.log(val, old)
},
{
deep: true
}
)