中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

做英文行程的網(wǎng)站汕頭自動seo

做英文行程的網(wǎng)站,汕頭自動seo,做家具的外國網(wǎng)站,外貿(mào)型網(wǎng)站建設(shè)公司文章目錄 1,入門案例輔助函數(shù) 2,mutations傳參輔助函數(shù) 3,actions輔助函數(shù) 4,getters輔助函數(shù) 5,模塊拆分6,訪問子模塊的state輔助函數(shù) 7,訪問子模塊的getters輔助函數(shù) 8,訪問子模塊…

文章目錄

  • 1,入門案例
    • 輔助函數(shù)
  • 2,mutations傳參
    • 輔助函數(shù)
  • 3,actions
    • 輔助函數(shù)
  • 4,getters
    • 輔助函數(shù)
  • 5,模塊拆分
  • 6,訪問子模塊的state
    • 輔助函數(shù)
  • 7,訪問子模塊的getters
    • 輔助函數(shù)
  • 8,訪問子模塊的mutations
    • 輔助函數(shù)
  • 9,訪問子模塊的actions
    • 輔助函數(shù)

1,入門案例

安裝庫。

npm install vuex@3

新建store.js。

import Vue from 'vue'
import Vuex from 'vuex'Vue.use(Vuex)const store = new Vuex.Store({state: {count: 0},mutations: {increment(state) {state.count++}}
})export default store

main.js。

new Vue({render: h => h(App),store
}).$mount('#app')

最后,計數(shù)器案例。

<template><h1 @click="add">{{ $store.state.count }}</h1>
</template><script>
export default {name: 'App',methods: {add() {this.$store.commit('increment')}}
}
</script>

效果:

在這里插入圖片描述

輔助函數(shù)

可以將數(shù)據(jù)自動變成計算屬性。

<template><h1 @click="add">{{ count }}</h1>
</template><script>
import { mapState } from "vuex";
export default {name: 'App',methods: {add() {this.$store.commit('increment')}},computed: {...mapState(['count'])}
}
</script>

2,mutations傳參

跟著后面寫就行,只能傳一個參數(shù)。

const store = new Vuex.Store({state: {count: 0},mutations: {increment(state, v) {state.count += v}}
})this.$store.commit('increment', 5)

輔助函數(shù)

可以將mutations自動變成方法。

<template><h1 @click="increment(5)">{{ count }}</h1>
</template><script>
import { mapState, mapMutations } from "vuex";
export default {name: 'App',methods: {...mapMutations(['increment'])},computed: {...mapState(['count'])}
}
</script>

3,actions

異步操作數(shù)據(jù)。

const store = new Vuex.Store({state: {count: 0},mutations: {increment(state, v) {state.count += v}},actions: {incrementAction(context, v) {setTimeout(() => {context.commit('increment', v)}, 1000)}}
})this.$store.dispatch('incrementAction', 5)

輔助函數(shù)

可以將actions自動變成方法。

<template><h1 @click="incrementAction(5)">{{ count }}</h1>
</template><script>
import { mapState, mapMutations, mapActions } from "vuex";
export default {name: 'App',methods: {...mapActions(['incrementAction']),...mapMutations(['increment'])},computed: {...mapState(['count'])}
}
</script>

4,getters

派生狀態(tài),類似于計算屬性。

const store = new Vuex.Store({state: {count: 0},mutations: {increment(state, v) {state.count += v}},actions: {incrementAction(context, v) {setTimeout(() => {context.commit('increment', v)}, 1000)}},getters: {count1(state) {return state.count + "個"}}
})$store.getters.count1 

輔助函數(shù)

可以將getters自動變成計算屬性。

<template><h1 @click="incrementAction(5)">{{ count1 }}</h1>
</template><script>
import { mapState, mapMutations, mapActions, mapGetters } from "vuex";
export default {name: 'App',methods: {...mapActions(['incrementAction']),...mapMutations(['increment'])},computed: {...mapState(['count']),...mapGetters(['count1'])}
}
</script>

5,模塊拆分

新建a.js。

新增了一個配置項namespaced。

export default {namespaced: true,state: {count: 0},mutations: {increment(state, v) {state.count += v}},actions: {incrementAction(context, v) {setTimeout(() => {context.commit('increment', v)}, 1000)}},getters: {count1(state) {return state.count + "個"}}
}

b.js。

export default {namespaced: true,state: {count: 0},mutations: {increment(state, v) {state.count += v}},actions: {incrementAction(context, v) {setTimeout(() => {context.commit('increment', v)}, 1000)}},getters: {count1(state) {return state.count + "個"}}
}

改寫store.js。

const store = new Vuex.Store({modules: {a, b}
})

6,訪問子模塊的state

$store.state.a.count
$store.state.b.count

輔助函數(shù)

<template><div><h1>{{ count }}</h1></div>
</template><script>
import { mapState } from "vuex";
export default {computed: {...mapState('a', ['count'])}
}
</script>

7,訪問子模塊的getters

$store.getters['a/count1']
$store.getters['b/count1']

輔助函數(shù)

用法與前面一致。

8,訪問子模塊的mutations

this.$store.commit('a/increment', 1)

輔助函數(shù)

用法與前面一致。

9,訪問子模塊的actions

this.$store.dispatch('a/incrementAction', 1)

輔助函數(shù)

用法與前面一致。

http://www.risenshineclean.com/news/3053.html

相關(guān)文章:

  • 濟(jì)南企業(yè)做網(wǎng)站網(wǎng)絡(luò)營銷策劃案例
  • 寧波網(wǎng)站建設(shè)方案報價四川seo平臺
  • 不花錢自己可以做網(wǎng)站嗎專門搜索知乎內(nèi)容的搜索引擎
  • 宣傳冊內(nèi)容排版揚(yáng)州seo
  • 怎樣php網(wǎng)站建設(shè)河南網(wǎng)站建設(shè)公司哪家好
  • 北京智能網(wǎng)站建設(shè)系統(tǒng)加盟怎么用網(wǎng)絡(luò)推廣業(yè)務(wù)
  • 在做網(wǎng)站編代碼網(wǎng)頁導(dǎo)航條中的文字出現(xiàn)在導(dǎo)航條的下方怎莫解決東莞有限公司seo
  • 網(wǎng)站建設(shè)的一般步驟精準(zhǔn)粉絲引流推廣
  • 成都哪里做網(wǎng)站便宜百度的合作網(wǎng)站有哪些
  • 網(wǎng)站建設(shè)實訓(xùn)內(nèi)容廣東東莞疫情最新消息今天又封了
  • 什么情況下需要建設(shè)網(wǎng)站蘋果自研搜索引擎或為替代谷歌
  • 成都網(wǎng)站建設(shè)博客國際新聞最新消息十條摘抄
  • 時光軸網(wǎng)站模板關(guān)鍵詞在線聽
  • 龍巖新聞網(wǎng)龍巖kk社區(qū)搜索引擎外部鏈接優(yōu)化
  • 地方門戶網(wǎng)站建站流程杭州百度seo優(yōu)化
  • wordpress商城建站教程創(chuàng)建網(wǎng)站要錢嗎
  • 永久免費自助建站朋友圈廣告投放價格表
  • 織夢網(wǎng)站首頁打開慢鄭州企業(yè)網(wǎng)絡(luò)推廣外包
  • 做網(wǎng)站做的好的公司有哪些免費網(wǎng)站排名優(yōu)化軟件
  • 甘肅做網(wǎng)站哪家專業(yè)推廣計劃方案模板
  • 深圳 電子商務(wù)網(wǎng)站開發(fā)在線智能識圖
  • wordpress圖片批量上傳插件下載游戲優(yōu)化大師
  • 請人幫忙做網(wǎng)站推廣seo自學(xué)網(wǎng)官網(wǎng)
  • 建設(shè)工程網(wǎng)教育網(wǎng)官網(wǎng)河南鄭州網(wǎng)站推廣優(yōu)化外包
  • 幼兒園主題設(shè)計網(wǎng)絡(luò)圖seo關(guān)鍵詞分析
  • 做網(wǎng)站選什么主機(jī)手機(jī)優(yōu)化器
  • 茂名網(wǎng)站建設(shè)服務(wù)培訓(xùn)心得體會500字
  • 松江集團(tuán)網(wǎng)站建設(shè)外鏈相冊
  • 2017政府網(wǎng)站設(shè)計方案百度一下你就知道官方
  • 自己怎么做團(tuán)購網(wǎng)站優(yōu)化步驟