JSON.parse 返回 [Object] 而不是值

问题描述

我正在使用 JSON.parse 来解析我的 JSON 并检索以下两个值,但是当我使用 <script> export default { data() { filtereddata: { title: '',district: 'all' },showing: 2,sort: '',},computed: { totalblog() { return this.temp.length },temp() { if (this.filtereddata.district === 'all') { return this.properties.filter(x => x.title.toLowerCase().includes(this.filtereddata.title)) } else { return this.properties.filter(x => x.title.toLowerCase().includes(this.filtereddata.title) && x.district === this.filtereddata.district) } },filteredproperties() { return this.sortProperties(this.temp) },methods: { sortProperties(list) { let temp = [...list] if (this.sort === 'rentlow') { temp.sort((a,b) => { return a.rent - b.rent }) } if (this.sort === 'renthigh') { temp.sort((a,b) => { return b.rent - a.rent }) } if (this.sort === 'arealow') { temp.sort((a,b) => { return a.area - b.area }) } if (this.sort === 'areahigh') { temp.sort((a,b) => { return b.area - a.area }) } return temp.slice(0,this.showing) },} </script> 时,它返回为 [Object] 成功

的实际价值
JSON.parse(test)

请在下面找到我的代码:

results.createSubProd.successSubProdct.status
results.createSubProd.failureSubProdct

输出:

var test = '{"name":"Mark","age":"20","params":{},"results":{"createProduct":{"status":"success","desc":"test"},"addProduct":{"status":"success"},"createSubProd":{"successSubProdct":{"status":"success"},"failureSubProdct":{"status":"success"}},"addToCache":{"status":"success"}}}'
console.log(JSON.parse(test))

为什么它返回 [Object] 像这样 { name: 'Mark',age: '20',params: {},results: { createProduct: { status: 'success',desc: 'test' },addProduct: { status: 'success' },createSubProd: { successSubProdct: [Object],failureSubProdct: [Object] },addToCache: { status: 'success' } } } 而不是 createSubProd: { successSubProdct: [Object],failureSubProdct: [Object] }

这里有什么问题,你能帮我解决这个问题吗?谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)