当前位置: 首页 > news >正文

使用JSON.stringify报错:Uncaught TypeError: cyclic object value

  • 具体错误
Uncaught TypeError: cyclic object value
    onMouseOver Amap.vue:125
    renderMarker Amap.vue:84
    emit maps:1
    emit maps:1
    ci maps:1
    ui maps:1
    fireEvent maps:1
    jL maps:1
    Xt maps:1
    T maps:1
    <anonymous> amap.vue:49
    promise callback*nextTick runtime-core.esm-bundler.js:242
    <anonymous> amap.vue:48
    promise callback* amap.vue:47
    <anonymous> amap.vue:42
    register useRegister.ts:102
    useRegister useRegister.ts:64
    node_modules chunk-A2DP46KH.js:8733
    callWithErrorHandling runtime-core.esm-bundler.js:158
    callWithAsyncErrorHandling runtime-core.esm-bundler.js:166
    __weh runtime-core.esm-bundler.js:2655
    flushPostFlushCbs runtime-core.esm-bundler.js:325
    flushJobs runtime-core.esm-bundler.js:363
    promise callback*queueFlush runtime-core.esm-bundler.js:270
    queueJob runtime-core.esm-bundler.js:264
    reload runtime-core.esm-bundler.js:464
    tryWrap runtime-core.esm-bundler.js:494
    <anonymous> Amap.vue:304
    accept client.ts:564
    fetchUpdate client.ts:481
    queueUpdate client.ts:328
    queueUpdate client.ts:328
    handleMessage client.ts:181
    handleMessage client.ts:179
    setupWebSocket client.ts:96
    setupWebSocket client.ts:95
    <anonymous> client.ts:69
7 Amap.vue:125:35
  • 解决办法

输出key和value,检查哪个是object类型,逐个排除。比如我经过输出,判断如下:

const onMouseOver = (event, marker) => {

  let jsonString = JSON.stringify(event, function(key, value) {
    //console.log(key+", "+value);
    if (key === 'target') {
        return undefined; // 忽略循环引用属性
    }
    return value;
  });
  console.log("event="+jsonString);

  jsonString = JSON.stringify(marker, function(key, value) {
    //console.log(key+", "+value);
    if (key === 'context'
      || key === '_map'
      || key == '_parent' ) {
        return undefined; // 忽略循环引用属性
    }
    return value;
  });

http://www.dtcms.com/a/108314.html

相关文章:

  • RNN模型与NLP应用——(6/9)Text Generation(文本自动生成)
  • UE小:在Unreal Engine 5中实现多层静态网格体遮挡拾取
  • 【落羽的落羽 C++】模板简介
  • 交易引擎中的设计模式
  • 「青牛科技」GC5331 5V三相无感正弦波电机驱动芯片 对标茂达APX9331/灿瑞OCH2360
  • Spring Cloud Gateway 的核心作用
  • Flutter项目之登录注册功能实现
  • Debian/Ubuntu的networking的`/etc/network/interfaces`配置文件,如何配置route路由
  • SQL问题分析与诊断(8)——关键信息(2)
  • 数据结构----栈
  • LangChain/Eliza框架在使用场景上的异同,Eliza通过配置实现功能扩展的例子
  • 【力扣hot100题】(036)二叉树的最大深度
  • Spring Boot 工程创建详解
  • 小游戏中Enable Exceptions的各选项有何区别
  • 基于开源AI大模型与S2B2C模式的线下服务型门店增长策略研究——以AI智能名片与小程序源码技术为核心
  • 从静态到动态:D * 算法如何革新机器人路径规划
  • 图形渲染: tinyrenderer 实现笔记(Lesson 1 - 4)
  • ATEngin开发记录_1_在Vsiual Studio2022中使用ReShaper创建类模板
  • 理解激活函数,多个网络层之间如何连接
  • 红宝书第二十七讲:详解WebAssembly与asm.js如何实现高效执行
  • 七种分布式ID生成方式详细介绍--Redis、雪花算法、号段模式以及美团Leaf 等
  • 二分查找与二分答案入门c++
  • 如何对后端API进行负载测试
  • vue将组件中template转为js
  • codeforces C. Creating Keys for StORages Has Become My Main Skill
  • systemd服务开机启动(code=exited, status=203/EXEC)错误,由于SELinux 开启安全模式
  • AI知识补全(十五):AI可解释性与透明度是什么?
  • 详细说明一下C++中的static关键字
  • 火山引擎coze用户市场
  • 使用PyTorch实现GoogleNet(Inception)并训练Fashion-MNIST