Closed sujiewen closed 3 years ago
state.visitedViews.push( Object.assign({}, this.$route, { title: view.meta.title || 'no-name' }) ) 这里深拷贝有问题,改怎么解决?
这看上去是 $route 里有用 Symbol 做 key 的, 但我们存储的介质是 localstorage, 无法存储 Symbol
应该是$route里面有对象嵌套引起的
应该是$route里面有对象嵌套引起的 @sujiewen 怎么解决的
应该是$route里面有对象嵌套引起的 @sujiewen 怎么解决的
我换了vuex-persistedstate插件就能解决了,是这个插件复制逻辑引起的,每次都是全部深度克隆整个state,state对象的属性中存储的某个对象有Symbol 做 key 的话,就会报错
如果不使用vuexAlong 就没有问题的
代码是这样的:
this.$store.dispatch('tagsView/addView', this.$route)
store 下面代码是这样的 const actions = { addView({ dispatch }, view) { dispatch('addVisitedView', view) dispatch('addCachedView', view) }, addVisitedView({ commit }, view) { commit('ADD_VISITED_VIEW', view) }, addCachedView({ commit }, view) { commit('ADD_CACHED_VIEW', view) } }
commit('ADD_VISITED_VIEW', view)执行这个代码就会引起这个问题