In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the Vue array appears in the _ _ ob__:Observer can not take the value of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone read this Vue array can not take a value of the problem of how to solve the article will have a harvest, let's take a look.
Problem description
In development projects, you often have to get an array from a database and copy it to a new array, but sometimes you will find that there is no way to get the value with the _ _ ob__: Observer array suffix, but what is even more frightening is that console.log can see the value. The array is shown in the following figure:
Solve the problem
Well, to solve this problem, blogs are basically talking about converting arrays into string objects, using this JSON.parse (JSON.stringify (array)) to assign values, and then manipulating the array to become empty! To tell you the truth, this is not the reason at all. I was cheated all afternoon!
So first explain why _ _ ob__: Observer appears after the array, this suffix is actually generated by the Vue monitoring variable, and _ _ ob__: Observer will appear if you use the object information added by push.
_ _ ob__: Observer doesn't mean it can't be traversed or enumerated, so why on earth can't get the value? Just because you're in such a hurry.
We should consider that the way we use vue to take values is Ajax asynchronous. In other words, before you get the values from the database and put them in the corresponding array, you start to get the values. That must be impossible to get, so we can have two ways. First, change this to synchronous form and then take the values after you have loaded them. In other words, the second way is to set a delay and wait for it to be picked up after you assign the value! Then you can see the value.
Mounted () {setTimeout (()) = > {/ / write the statement you want to execute here. Just load the data from the database into the array and you can take values from the array}, 800)} result diagram
This is the end of the article on "how to solve the problem that _ _ ob__:Observer cannot be taken in the Vue array". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to solve the problem that the value of _ _ ob__:Observer cannot be taken in the Vue array". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.