TypeError Converting circular structure to JSON --> starting at object with constructor ‘Vue‘

编程知识 行业动态 更新时间:2024-06-13 00:21:58

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/xiaojinglyd/article/details/103489651

【2】https://blog.csdn/Amnesiac666/article/details/108635236

更多推荐

TypeError Converting circular structure to JSON --> starting at object with cons

本文发布于:2023-04-01 11:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/73a3c876184b1de00a36d964d41e17e4.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:circular   structure   TypeError   Converting   JSON

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!