vue3 vuex 同步数据
import { useStore } from 'vuex';
let store = useStore();
const item = computed(() => {
return {
name: store.state.printerName,
deviceId: store.state.deviceId,
services: [
{
serviceId: store.state.serviceId,
characteristicId: store.state.characteristicId
}
]
}
})
store.commit('SET_PRINTNAME', dev.name)
store.commit('SET_DEVICEID', dev.deviceId)
state: {
printerName: '',
deviceId: '',
serviceId: '',
characteristicId: ''
},
mutations: {
SET_PRINTNAME(state, name) {
state.printerName = name
},
SET_DEVICEID(state, id) {
state.deviceId = id
},
SET_SERVICEID(state, serviceId) {
state.serviceId = serviceId
},
SET_CHARACTERISTICID(state, cId) {
state.characteristicId = cId
},
},
本文来自博客园,作者:格林格林,转载请注明原文链接:https://www.cnblogs.com/beiyi-Lin/p/18755301

浙公网安备 33010602011771号