先看代码
import Vuex from ‘vuex‘ import Vue from ‘vue‘ Vue.use(Vuex); const store = new Vuex.Store({ state: { count: 0 }, mutations: { increment (state) { state.count++ } } }); store.commit(‘increment‘); console.log(store.state.count);
设置bable的配置文件:.babelrc
"presets": [‘es2015‘]
在终端运行:
babel vuex.js -o 2.js node 2.js
结果为:
1
时间: 2024-09-28 16:07:57