(1)使用computed一个一个解析

import {useStore} from 'vuex'
import {computed} from 'vue'

const store=useStore()
const state=computed(()=>store.state.name)

(2)使用mapState全部解析

const storeState=mapState(['count','name'])
const state={}

Object.keys(storeState).forEach(Key=>{
	const fn=storeState[Key].bind({$store:store})
	state[Key]=computed(fn)
})
返回...state就行了
Logo

前往低代码交流专区

更多推荐