zoukankan      html  css  js  c++  java
  • Vuex:Mutation常量类型

    1  作用

    用常量替代 Mutation 事件类型。可以方便大型项目的命名规范

    2 文件结构

    3 代码

    3.1 srcstoremutations-types.js

    export const INCREMENT = 'increment'

    3.2 srcApp.vue

    //1 导入  
    import {INCREMENT} from "./store/mutations-types"
    //2 使用methods:{
          addition(){
            this.$store.commit(INCREMENT)
          },
          subtraction(){
            this.$store.commit('decrement')
          }
        }

    3.3 srcstoreindex.js

    //1导入 
    import * as myMutations  from "@/store/mutations-types"
    mutations:{
        //方法 默认带state参数
        [myMutations.INCREMENT](state){
          state.counter++
        },
        decrement(state){
          state.counter--
        }
      },

     

  • 相关阅读:
    开发mis系统的技术
    Navicat软件与pymysql模块
    5.6作业
    mysql表的查询
    5.5作业
    约束条件
    mysql基本数据类型
    数据库
    网络编程项目
    并发编程四
  • 原文地址:https://www.cnblogs.com/polax/p/13231466.html
Copyright © 2011-2022 走看看