es6计算属性名

es6计算属性名

let name = "first name"
let person = {
    
    
  [name]:"Raaa",
  ["last" + "name"]: "bbit",
  ["say"+"Hello"](){
    
    
    console.log('hello')
  }
}

// vuex中的使用

// mutation-types.js
export const SOME_MUTATION = 'SOME_MUTATION'

// store.js
import Vuex from 'vuex'
import {
    
     SOME_MUTATION } from './mutation-types'

const store = new Vuex.Store({
    
    
  state: {
    
     ... },
  mutations: {
    
    
    // 我们可以使用 ES2015 风格的计算属性命名功能来使用一个常量作为函数名
    [SOME_MUTATION] (state) {
    
    
      // mutate state
    }
  }
})

猜你喜欢

转载自blog.csdn.net/qq_36303110/article/details/112174461