zoukankan      html  css  js  c++  java
  • vue ssr 服务端 路由 报错 err= TypeError: Converting circular structure to JSON

    • 代码:
          let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
          matched.map(val => {
            // 解决方法
            val.instances = {}
          })
          // levelList = this.jsons(levelList)
          this.$store.commit('app/TOGGLE_NEVLIST', this.levelList)
    
    • 报错:
    error during render : url=/rank/soft err= TypeError: Converting circular structure to JSON
         --> starting at object with constructor 'Vue'
         |     property '$options' -> object with constructor 'Object'
         |     property 'router' -> object with constructor 'VueRouter'
         --- property 'app' closes the circle
         at JSON.stringify (<anonymous>)
    
    • 解决思路:
    1. vue的 $router在执行的时候会使用JSON.stringify去处理路由
    2. node环境中是拒绝循环引用的1.
    3. this.$route.matched.filter返回的数据中 instances 执行 当前的对象(暂时认为是当前路由对象,欢迎举证)
    4. 上面(1)中 存在循环引用 报错
    5. 把instances 指向空对象能避免后面路由的使用报错
  • 相关阅读:
    二次剩余
    【2020.9.29 NOIP模拟赛 T3】寻梦(fantasy)
    Graph and Queries
    势函数和鞅的停时定理学习笔记
    毒瘤计数题汇总
    2-SAT
    CF559E Gerald and Path
    [SDOI2019]世界地图
    CF1349D Slime and Biscuits
    AT4928 [AGC033E] Go around a Circle
  • 原文地址:https://www.cnblogs.com/YOUNGZZ/p/13633323.html
Copyright © 2011-2022 走看看