vuex 简单使用
2018-03-22 10:57
239 查看
在vue 组件中
执行enabledcheckbox方法 ,true 为参数,用来改变state中的值
从state获取useredit的值
2 在vuex导出的对象对添加 值到state
添加 mutations 来改变state的值
添加 actions 来 mutations
在main.js
执行enabledcheckbox方法 ,true 为参数,用来改变state中的值
this.$store.dispatch("enabledcheckbox",true)
从state获取useredit的值
this.$store.state.useredit
2 在vuex导出的对象对添加 值到state
添加 mutations 来改变state的值
添加 actions 来 mutations
import Vue from 'vue' import vuex from 'vuex' Vue.use(vuex) export default new vuex.Store({ state: { useredit: false, }, mutations: { ENABLEDCHECKBOX(state, value) { state.checkboxDisable = value }, }, actions: { enabledcheckbox({ commit }, value) { commit('ENABLEDCHECKBOX', value) }, } }) //console.log(vuex)
在main.js
import store from './vuex' new Vue({ el: '#app', router, store, render:h=>h(App) })
相关文章推荐
- vue 表单验证 vee-validate 简单使用
- vuex在vue-cli和webpack构建的项目中的简单使用
- SSM框架中简单使用Solr和Vue.js
- vue中 router-link的简单使用
- 使用Vue-cli搭建后台简单管理系统vue.js2.0
- 结合Vue使用的简单分页器
- vuex 的简单使用
- Vue的路由功能(1)简单路由与vue-router的基础使用(同步/异步组件)
- Asp.net+Vue2构建简单记账WebApp之三(使用Vue-cli构建vue.js应用)
- Vue的路由功能(1)简单路由与vue-router的基础使用(同步/异步组件)
- 简单的vuex 的使用案例笔记
- vue-resource和vue-axios的简单使用方法
- vue 2 使用Bus.js进行兄弟(非父子)组件通信 简单案例
- vue简单使用
- 使用vue + less 实现简单换肤功能的示例
- vue.js的简单使用及组件套用
- vue 2 使用Bus.js进行兄弟(非父子)组件通信 简单案例
- Asp.net+Vue2构建简单记账WebApp之三(使用Vue-cli构建vue.js应用)
- 详解在vue-cli项目下简单使用mockjs模拟数据
- axios在vue中的简单配置与使用