一、问题描述 当我登录使用了elementUI的vue2项目时,输入用户名密码点击确定,报如下错误。 TypeError: sub is not a functionat vuex.esm.js:422:1at Array.forEach (<anonymous>)at Store.dispatch (vuex.esm.js:422:1)at Store.boundDispatch [as dispatch] (vuex.esm.js:332:1)at permissionsControl (...
一般在vue2.x项目中我们会使用Vue DevTools插件来帮助我们开发,但是今天项目突然出现bug,调用vuex的dispatch方法时突然出现报错,如下: TypeError:sub is not afunctionateval(vuex.esm.js?2f62:422:1)at Array.forEach(<anonymous>)at Store.dispatch(vuex.esm.js?2f62:422:1)at Store.boundDispatch[asdispatch...
新版vue devTools在旧项目中打开 会出现vuex报错,关闭调试工具时正常 TypeError: sub is not a function ateval(vuex.esm.js) 处理方式: 查看github上有人提的issue https://github.com/vuejs/devtools/issues/1686 调试工具中可以vue3.0以下版本不开启新功能 GitHub上没说具体步骤 找了半天 按步骤开启 就能正常...
因为mutation名字是唯一的,这里进行了常量形式的调用,防止命名重复,执行跟源码分析中一致,调用function wrappedMutationHandler (payload) { handler(local.state, payload)} 封装函数来实际调用配置的mutation方法。
export function initUse(Vue: GlobalAPI) { Vue.use = function (plugin: Function | any) { // 存放所有已经安装的plugin const installedPlugins = this._installedPlugins || (this._installedPlugins = []) if (installedPlugins.indexOf(plugin) > -1) { ...
functionresetStoreVM(store,state,hot){// 省略若干代码store._vm=newVue({data:{$$state:state},computed})// 省略若干代码} 这里的state就是 用户定义的state。这里的computed就是处理后的用户定义的getters。而class Store上的一些函数(API)主要都是围绕修改vm.$store._vm._data.$$state和computed(getter)...
forEach(function commitIterator (handler) { handler(payload); }); }); // 调用commit更改state时,调用所有插件中订阅的方法 this._subscribers .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe .forEach(sub => sub(mutation, this.state)); } ...
entry.forEach(functioncommitIterator(handler){ handler(payload) }) }) this._subscribers.forEach(sub=>sub(mutation,this.state)) //开发模式下的silent判断 if( process.env.NODE_ENV!=='production'&& options&&options.silent ){ console.warn( ...
forEach(function commitIterator (handler) { handler(payload) }) }) // 如果有订阅函数存在,则逐个执行 this._subscribers .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe .forEach(sub => sub(mutation, this.state)) if ( __DEV__ && options...
function(plugin:Function|Object){/* istanbul ignore if */if(plugin.installed){return}// additional parametersconstargs=toArray(arguments,1)args.unshift(this)if(typeofplugin.install==='function'){// 实际执行插件的install方法plugin.install.apply(plugin,args)}else{plugin.apply(null,args)}plugin.ins...