Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem that console.log print result is [object Object]

Shulou Source: shulou.com Published: 2022-05-31 18:23:09 09月29日 Update

This article mainly introduces the console.log print result is [object Object] how to solve the related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this console.log print result is [object Object] how to solve the article will be harvested, let's take a look at it.

console.log print result is [object Object] problem

Before using + to connect, such as: console.log ("front parameter param is: "+self.filters.ip)

The result is: [Object Object]

solutions

In a VUE file, the original data of the print splice is separated by, such as

console.log ("front-end param yes: ", self.filters.ip)

The results are displayed normally:

Object and object[object]

In the process of doing the project, I accidentally found that the result obtained by using object[object] and object.object is the same, which makes me feel very surprised. After all, object[object] was used in arrays before, and has not been used like this.

Case const lineChartData = { newVisitis: { expectedData: ['2020-12- 1','2020-12- 2','2020-12- 3','2020-12- 4','2020 -12- 5','2020-12- 6','2020-12- 7'], //Daily enrollment date actualData: [120, 82, 91, 154, 162, 140, 145] //Daily signups}, messages: { expectedData: [200, 192, 120, 144, 160, 130, 140], actualData: [180, 160, 151, 106, 145, 150, 130] }, purchases: { expectedData: [80, 100, 121, 104, 105, 90, 100], actualData: [120, 90, 100, 138, 142, 130, 130] }, shoppings: { expectedData: [130, 140, 141, 142, 145, 150, 160], actualData: [120, 82, 91, 154, 162, 140, 130] }}

As above, if we use objects inside newVisitis, then we must get them through this.lineChartData.newVisitis.

But at this time we can also get it through **this.lineChartData[newVisitis]**

The code is as follows:

methods: { handleSetLineChartData(type) { console.log(type) console.log( lineChartData[type]," lineChartData[purchases]") console.log( lineChartData.purchases," lineChartData.purchases") this.lineChartData = lineChartData[type] } }

The results were as follows:

About "console.log print result is [object Object] how to solve" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "console.log print result is [object Object] how to solve". If you still want to learn more knowledge, please pay attention to the industry information channel.

Tags: Results knowledge number of people content front end parameters article original code value such as above object sense simple operation data array file article scheme date Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple NVidia macOS vpn Huawei