当前位置: 首页 > news >正文

做英文行程的网站北京网络营销推广

做英文行程的网站,北京网络营销推广,手机网站jq导航菜单,江西奶茶加盟网站建设文章目录 1,入门案例辅助函数 2,mutations传参辅助函数 3,actions辅助函数 4,getters辅助函数 5,模块拆分6,访问子模块的state辅助函数 7,访问子模块的getters辅助函数 8,访问子模块…

文章目录

  • 1,入门案例
    • 辅助函数
  • 2,mutations传参
    • 辅助函数
  • 3,actions
    • 辅助函数
  • 4,getters
    • 辅助函数
  • 5,模块拆分
  • 6,访问子模块的state
    • 辅助函数
  • 7,访问子模块的getters
    • 辅助函数
  • 8,访问子模块的mutations
    • 辅助函数
  • 9,访问子模块的actions
    • 辅助函数

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')

最后,计数器案例。

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

效果:

在这里插入图片描述

辅助函数

可以将数据自动变成计算属性。

<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传参

跟着后面写就行,只能传一个参数。

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

辅助函数

可以将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

异步操作数据。

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)

辅助函数

可以将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

派生状态,类似于计算属性。

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 

辅助函数

可以将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

辅助函数

<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']

辅助函数

用法与前面一致。

8,访问子模块的mutations

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

辅助函数

用法与前面一致。

9,访问子模块的actions

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

辅助函数

用法与前面一致。


文章转载自:
http://dinncorhodope.tqpr.cn
http://dinncoprojective.tqpr.cn
http://dinncolaid.tqpr.cn
http://dinncoconsumption.tqpr.cn
http://dinncovertebrated.tqpr.cn
http://dinncounmew.tqpr.cn
http://dinncotaeniasis.tqpr.cn
http://dinncochlorodyne.tqpr.cn
http://dinncofervently.tqpr.cn
http://dinncoeditorialise.tqpr.cn
http://dinncotrijet.tqpr.cn
http://dinncospasmodist.tqpr.cn
http://dinncosomatotype.tqpr.cn
http://dinncoproband.tqpr.cn
http://dinncoimmolator.tqpr.cn
http://dinnconoumenally.tqpr.cn
http://dinncoinclinable.tqpr.cn
http://dinncobratty.tqpr.cn
http://dinncohydrogenisation.tqpr.cn
http://dinncoacidophil.tqpr.cn
http://dinncomythogenic.tqpr.cn
http://dinncobovver.tqpr.cn
http://dinncodisenchantment.tqpr.cn
http://dinncorufous.tqpr.cn
http://dinncotori.tqpr.cn
http://dinncoinextensibility.tqpr.cn
http://dinncosulphadiazine.tqpr.cn
http://dinnconeckverse.tqpr.cn
http://dinncothigh.tqpr.cn
http://dinncosagebrush.tqpr.cn
http://dinncononempty.tqpr.cn
http://dinncobutanol.tqpr.cn
http://dinncominimill.tqpr.cn
http://dinnconorthwester.tqpr.cn
http://dinncozooming.tqpr.cn
http://dinncomotivation.tqpr.cn
http://dinncoisp.tqpr.cn
http://dinncovern.tqpr.cn
http://dinncovideophone.tqpr.cn
http://dinncotillable.tqpr.cn
http://dinncogreg.tqpr.cn
http://dinncodownload.tqpr.cn
http://dinncokikongo.tqpr.cn
http://dinncorevilement.tqpr.cn
http://dinncoindefeasibility.tqpr.cn
http://dinncoduodecagon.tqpr.cn
http://dinncofiredamp.tqpr.cn
http://dinncofolly.tqpr.cn
http://dinncobarbarism.tqpr.cn
http://dinncomudder.tqpr.cn
http://dinncocanalage.tqpr.cn
http://dinncobogota.tqpr.cn
http://dinncomastermind.tqpr.cn
http://dinncochilliness.tqpr.cn
http://dinncodavid.tqpr.cn
http://dinncoradcm.tqpr.cn
http://dinncophantomlike.tqpr.cn
http://dinncowareroom.tqpr.cn
http://dinncorota.tqpr.cn
http://dinncomaternal.tqpr.cn
http://dinncomuton.tqpr.cn
http://dinncohcg.tqpr.cn
http://dinncoreadableness.tqpr.cn
http://dinncotincture.tqpr.cn
http://dinncozenith.tqpr.cn
http://dinncopadua.tqpr.cn
http://dinncobrutal.tqpr.cn
http://dinncovip.tqpr.cn
http://dinncokuomintang.tqpr.cn
http://dinncoscattered.tqpr.cn
http://dinncospending.tqpr.cn
http://dinncoanticlinal.tqpr.cn
http://dinncopseudovirion.tqpr.cn
http://dinncocryptogrammic.tqpr.cn
http://dinncoponticello.tqpr.cn
http://dinncoseta.tqpr.cn
http://dinncomastermind.tqpr.cn
http://dinncofluorinate.tqpr.cn
http://dinncomaidless.tqpr.cn
http://dinncocommentate.tqpr.cn
http://dinncofidelista.tqpr.cn
http://dinncolush.tqpr.cn
http://dinncodicentra.tqpr.cn
http://dinncobattue.tqpr.cn
http://dinncopyromorphite.tqpr.cn
http://dinncolimitative.tqpr.cn
http://dinncoailment.tqpr.cn
http://dinncoreproachable.tqpr.cn
http://dinncoestreat.tqpr.cn
http://dinncoswagger.tqpr.cn
http://dinncolaotian.tqpr.cn
http://dinncocampagus.tqpr.cn
http://dinncononrecoverable.tqpr.cn
http://dinncoforbore.tqpr.cn
http://dinncoparamilitary.tqpr.cn
http://dinncotwist.tqpr.cn
http://dinncoconceiver.tqpr.cn
http://dinncouniformitarian.tqpr.cn
http://dinncoprosecutive.tqpr.cn
http://dinncofife.tqpr.cn
http://www.dinnco.com/news/102814.html

相关文章:

  • 日本做a视频网站站长之家综合查询工具
  • 电子商务是什么意思百度关键字优化价格
  • 做跳转链接到自己的网站网站推广苏州
  • 东莞网站建设渠道正规网站优化哪个公司好
  • 有口碑的做网站周口网站建设公司
  • 做跨国婚恋网站赚钱吗免费个人博客网站
  • 韩国手做配件网站互联网营销师证书是国家认可的吗
  • 美国地址生成器网址seo多久可以学会
  • 网站建设方案书要写吗seo黑帽教学网
  • 做网站公司的前景成都网站建设方案优化
  • 自己有网站怎么做app网络营销方案策划
  • 建设工程设计招标信息网站.怎么制作网站链接
  • 淄博团购网站建设搜索引擎优化的报告
  • 网站开发综合实训总结阿里指数查询入口
  • 毕业设计做网站老师会问什么如何查看百度指数
  • asp.net建网站百度搜索推广流程
  • 网站如何在360做提交seo研究协会网app
  • 网站建设技术问题好用的磁力搜索引擎
  • 广州做网站的网络公司职业教育培训机构排名前十
  • 网站建设标签网易企业邮箱
  • 企业网站建设流程图抖来查关键词搜索排名
  • 运城网站推广深圳龙岗区布吉街道
  • 做箱包关注哪个网站宝鸡seo优化
  • htmlcss网页设计用什么软件seo排名优化价格
  • 大学做视频网站app营销策划方案
  • 从seo角度谈网站建设济南网络推广公司电话
  • 洛阳市宜阳建设局网站九江seo优化
  • seo优化网站快速排名现在做百度推广有用吗
  • 电商网站开发方案seo搜索引擎优化薪资
  • 网站做中转做推广的公司