1. 安装webpack的问题: webpack坑系列--安装webpack-cli 2. vue-cli(vue脚手架)超详细教程 3. 在命令行中使用 touch 执行新建文件; 4. 关于Vue.use()详解 5. vuex 最简单的介绍 目录如左侧所示,主要是标红的三个文件。 5.1 store文件,编写vuex的各个功能,包括: import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const state = { // 定义状态数据 count: 2 } const mutations = { // 定义方法,操作数据 increment (state) { state.count ++ }, decrement (state) { state.count -- } } const actions = { add: ({commit}) => { // 触发上述的方法,对外提供的方法接口,可以在这里提供异步操作 commit('increment' ) }, reduce: ({commit}) => { commit( 'decrement' ) } } export default new Vuex.Store({state, mutations, actions}) 5.2 然后在main文件中