vue sessionStorage TypeError: Converting circular structure to JSON
vue-admin-template顶部网页加载横条特别慢,打开浏览器调试界面,发现报错TypeError: Converting circular structure to JSON --> starting at object with constructor ‘Vue’ ,
定位到permission.js中的代码
sessionStorage.setItem('routerTo', JSON.parse(JSON.stringify(to)))
这是存在循环引用【1】的错误
解决办法【2】:this.$store.state.tagsView.visitedViews替换为自己的变量即可
const visitedViews_temp = this.$store.state.tagsView.visitedViews
const arr_temp = []
for (let i = 0; i < visitedViews_temp.length; i++) {
arr_temp.push(visitedViews_temp[i].path)
}
if (arr_temp && arr_temp.length > 0) {
const temp = JSON.stringify(arr_temp)
sessionStorage.setItem('visitedViews', temp)
}
【1】https://blog.csdn.net/xiaojinglyd/article/details/103489651
【2】https://blog.csdn.net/Amnesiac666/article/details/108635236