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

天津响应式网站天津网站备案在哪照相

天津响应式网站,天津网站备案在哪照相,厦门建设与管理局官网,玉林seo文章目录 1#xff0c;入门案例辅助函数 2#xff0c;mutations传参辅助函数 3#xff0c;actions辅助函数 4#xff0c;getters辅助函数 5#xff0c;模块拆分6#xff0c;访问子模块的state辅助函数 7#xff0c;访问子模块的getters辅助函数 8#xff0c;访问子模块… 文章目录 1入门案例辅助函数 2mutations传参辅助函数 3actions辅助函数 4getters辅助函数 5模块拆分6访问子模块的state辅助函数 7访问子模块的getters辅助函数 8访问子模块的mutations辅助函数 9访问子模块的actions辅助函数 1入门案例 安装库。 npm install vuex3新建store.js。 import Vue from vue import Vuex from vuexVue.use(Vuex)const store new Vuex.Store({state: {count: 0},mutations: {increment(state) {state.count}} })export default storemain.js。 new Vue({render: h h(App),store }).$mount(#app)最后计数器案例。 templateh1 clickadd{{ $store.state.count }}/h1 /templatescript export default {name: App,methods: {add() {this.$store.commit(increment)}} } /script效果 辅助函数 可以将数据自动变成计算属性。 templateh1 clickadd{{ count }}/h1 /templatescript import { mapState } from vuex; export default {name: App,methods: {add() {this.$store.commit(increment)}},computed: {...mapState([count])} } /script2mutations传参 跟着后面写就行只能传一个参数。 const store new Vuex.Store({state: {count: 0},mutations: {increment(state, v) {state.count v}} })this.$store.commit(increment, 5)辅助函数 可以将mutations自动变成方法。 templateh1 clickincrement(5){{ count }}/h1 /templatescript import { mapState, mapMutations } from vuex; export default {name: App,methods: {...mapMutations([increment])},computed: {...mapState([count])} } /script3actions 异步操作数据。 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自动变成方法。 templateh1 clickincrementAction(5){{ count }}/h1 /templatescript import { mapState, mapMutations, mapActions } from vuex; export default {name: App,methods: {...mapActions([incrementAction]),...mapMutations([increment])},computed: {...mapState([count])} } /script4getters 派生状态类似于计算属性。 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自动变成计算属性。 templateh1 clickincrementAction(5){{ count1 }}/h1 /templatescript import { mapState, mapMutations, mapActions, mapGetters } from vuex; export default {name: App,methods: {...mapActions([incrementAction]),...mapMutations([increment])},computed: {...mapState([count]),...mapGetters([count1])} } /script5模块拆分 新建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辅助函数 templatedivh1{{ count }}/h1/div /templatescript import { mapState } from vuex; export default {computed: {...mapState(a, [count])} } /script7访问子模块的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://www.w-s-a.com/news/196703/

相关文章:

  • 网站开发技术 html临夏网站建设
  • flash网站模板免费下载拍卖网站开发多少钱
  • 北京网站建设制作颍州网站建设
  • 网站制作报价表做网站上海公司
  • 简洁大气蓝色文章资讯网站百度搜索广告推广
  • 河南建设工程协会网站网站收银系统建设
  • 网站制作 服务企业网站案例展示
  • 咸宁网站建设wordpress手动降级
  • 昆明做网站建设怎么样做网站赚钱全攻略
  • 企业网站建设实战教程微信如何注册小程序
  • 做一件代发网站百度seo服务
  • 小说网站开发 公司可以做行程的网站
  • 古交市网站建设公司apk连接wordpress
  • 网页 网 址网站区别wordpress菜单居右
  • 网站建设搭建运营一台云服务器做多个网站
  • 用php做网站用什么框架推广网站推荐
  • 如何用二级域名做网站多用户网上商城
  • 河南省建设科技网站浅谈电子商务网站建设与规划
  • 网站空间需要续费青海网站建设推广
  • 网站开发本地环境企业网站建设排名口碑
  • 做新闻的网站怎样赚钱个人网站课程设计报告
  • 网站设计样例那个网站做图片好看
  • 小型公司网站建设深圳网络营销策划有限公司
  • 国内优秀企业网站做视频网站用什么系统
  • 网站建设入门pdfwordpress网站标题
  • 专业网站的定义网站运营的概念
  • 外贸服装网站建设网页美工设计说明书
  • 郑州专业做网站公百度翻译api wordpress
  • 做网站哪里找大学的一级或二级域名
  • 没有静态ip可以做网站服务器上饶网站制作需要多少钱