文章詳情頁
javascript - vuex的mapState與其它c(diǎn)omputed屬性共存的正確寫法是?
瀏覽:194日期:2023-09-24 08:19:24
問題描述
mapState的官方示例使用方法是:
computed:mapState([’count’])
那其它不需要state的computed屬性應(yīng)該怎么寫呢?我試了
computed:{mapState([’count’]), age(){return this.old_age + 1;}}
會(huì)報(bào)錯(cuò)
computed:mapState([’count’, age(){return this.old_age + 1;}])
也會(huì)報(bào)錯(cuò),甚至
computed:{mapState([’count’])}
都會(huì)報(bào)錯(cuò) 請問正確的寫法應(yīng)該是怎樣的?
問題解答
回答1:提問之前能不能看看vuex官方文檔?computed: { localComputed () { / ... / }, // 使用對象展開運(yùn)算符將此對象混入到外部對象中 ...mapState({ // ... }) }如果不知道對象展開運(yùn)算符是什么麻煩去查es6/7的文檔
標(biāo)簽:
JavaScript
相關(guān)文章:
1. boot2docker無法啟動(dòng)2. docker-compose中volumes的問題3. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””4. docker容器呢SSH為什么連不通呢?5. java - SSH框架中寫分頁時(shí)service層中不能注入分頁類6. dockerfile - 為什么docker容器啟動(dòng)不了?7. 關(guān)于docker下的nginx壓力測試8. node.js - antdesign怎么集合react-redux對input控件進(jìn)行初始化賦值9. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.10. nignx - docker內(nèi)nginx 80端口被占用
排行榜

熱門標(biāo)簽
網(wǎng)公網(wǎng)安備