In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to solve the problem of value transfer and assignment in vue". In daily operation, I believe that many people have doubts about how to solve the problem of value transfer and assignment in vue. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer the doubt of "how to solve the problem of value transfer and assignment in vue". Next, please follow the editor to study!
Transfer and assignment of vue
As a non-experienced learner of Vue, I still encounter many so-called pits when I use vue at work, and I intend to sum it up; just yesterday PM found me and showed me a bug. It was a headache that I looked at the code for a long time, but I didn't see any problem, but it was an error report.
Take a look at the scene first.
This is the tab column of the details page. The general logic here is to jump from other pages to the details page and select the tab column of the virtual server group. The logic of the code is to get the details page information Detail first, and then pass the detail object to the virtual server group as a props to the subcomponent.
Export default {props: ['detail'], data () {return {type: this.detail.type}}, methods: {XXX () {}
I have taken one more step here, that is, the attribute in props is assigned to the variable in data, but if I jump to the details page and immediately go to the tab column of virtual service, (the XXX method will be triggered immediately, and the variable type will be used), the return will be wrong, that is, type is undefined?
Solution method
This will not happen if you directly use the detail variable in props without assigning a value to the variable in data.
The underlying reason is not clear, but the preliminary conclusion is the problem of time lag. During the test, it is found that this kind of bug is not bound to reappear, sometimes good or bad, and this problem can be avoided if it is used directly.
Vue assignment tips rigorous code
Rigor, that is, robustness, refers to the ability of the software to deal with input situations other than those required by the specification. The so-called system means that the input outside the specification requirements can be judged that the input does not meet the specification requirements, and there is a reasonable way to deal with it.
In addition, robustness sometimes overlaps with fault tolerance, portability, and correctness.
For example, a software can infer the correct and reasonable input from the wrong input, which is a fault-tolerant metric, but the software can also be considered robust.
Undefined judgment
There are two special data types in JS and Vue: undefined and null. The next section introduces the judgment of null, and let's talk about the judgment of undefined.
The following is incorrect usage:
Var exp = undefined;if (exp = = undefined) {alert ("undefined");}
When exp is null, you get the same result as undefined, although null and undefined are different. Note: this method can be used to judge undefined and null at the same time.
Var exp = undefined;if (typeof (exp) = = undefined) {alert ("undefined");}
The following is the correct usage:
Var exp = undefined;if (typeof (exp) = = "undefined") {alert ("undefined");} at this point, the study on "how to solve the problem of passing and assigning values in vue" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.