vuex
关于vuex的相关博客
尼克_张
好的代码像粥一样,是用时间熬出来的!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
vue中使用vuex
const store = new Vuex.Store({ state: { value:[] }, getters: {}, mutations: { elecPolicy(state,value){ //state里为初始值,value为你要存的值 state.value = value }, }, actions: {} }) //提交值 this.$store.commit(“key”,value) //获取值 this.KaTeX parse error: Expected '}', got '原创 2020-06-10 17:50:24 · 288 阅读 · 0 评论 -
vuedraggable结合vuex使用
computed: { //不应该直接这么写 pageInfo() { return this.$store.state.pageInfo; }, //而应该这样 pageInfo: { get() { return this.$store.state.pageInfo }, set(value) { this.$store.commit('updateList', value) } }, }原创 2021-01-15 11:20:49 · 807 阅读 · 1 评论 -
mapState与mapGetters语法糖
vuex中的 mapState,mapGetters 属于辅助函数,其实就是vuex的一个语法糖,使代码更简洁更优雅。 <script> import { mapState, mapGetters } from "vuex" export default { computed: { //原先 templateInfo(){ return this.$store.state.templateInfo }, //现在原创 2020-11-17 22:44:56 · 2663 阅读 · 2 评论
分享