• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

joer717

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

module.hot

import Vuex from 'vuex'

import defaultState from './state/state'
import mutations from './mutations/mutations'
import getters from './getters/getters'
import actions from './actions/actions'

const isDev = process.env.NODE_ENV === 'develpment';
export default () => {
  const store =  new Vuex.Store({
    strict: isDev , // 规范开发,禁止在非mutations内修改data的数据,正式环境改为false
    state: defaultState,
    mutations,
    getters,
    actions,
  })
  if(module.hot){
    module.hot.accept([
      './state/state',
      './mutations/mutations',
      './actions/actions',
      './getters/getters'
    ], ()=> {
      const  newState =require('./state/state').default;
      const  newmutations =require('./mutations/mutations').default;
      const  newActions =require('./actions/actions').default;
      const  newGetters =require('./getters/getters').default;

      // 热更新
      store.hotUpdate({
        state:newState,
        mutations:newmutations,
        getters:newActions,
        actions:newGetters,
      })
    })
  }
  return store
}

  

posted on 2019-08-05 14:59  joer717  阅读(392)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3