欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 产业 > 使用JSON.stringify报错:Uncaught TypeError: cyclic object value

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

2025/4/3 15:20:18 来源:https://blog.csdn.net/quantum7/article/details/146946771  浏览:    关键词:使用JSON.stringify报错:Uncaught TypeError: cyclic object value
  • 具体错误
Uncaught TypeError: cyclic object valueonMouseOver Amap.vue:125renderMarker Amap.vue:84emit maps:1emit maps:1ci maps:1ui maps:1fireEvent maps:1jL maps:1Xt maps:1T maps:1<anonymous> amap.vue:49promise callback*nextTick runtime-core.esm-bundler.js:242<anonymous> amap.vue:48promise callback* amap.vue:47<anonymous> amap.vue:42register useRegister.ts:102useRegister useRegister.ts:64node_modules chunk-A2DP46KH.js:8733callWithErrorHandling runtime-core.esm-bundler.js:158callWithAsyncErrorHandling runtime-core.esm-bundler.js:166__weh runtime-core.esm-bundler.js:2655flushPostFlushCbs runtime-core.esm-bundler.js:325flushJobs runtime-core.esm-bundler.js:363promise callback*queueFlush runtime-core.esm-bundler.js:270queueJob runtime-core.esm-bundler.js:264reload runtime-core.esm-bundler.js:464tryWrap runtime-core.esm-bundler.js:494<anonymous> Amap.vue:304accept client.ts:564fetchUpdate client.ts:481queueUpdate client.ts:328queueUpdate client.ts:328handleMessage client.ts:181handleMessage client.ts:179setupWebSocket client.ts:96setupWebSocket 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;});

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词