In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how vue assigns all the key in the object to null values". In the daily operation, I believe that many people have doubts about how vue assigns all the key in the object to null values. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how vue assigns all the key in the object to null values". Next, please follow the editor to study!
Assign all key in the object to null values
The use of Object.assign, of course, you can also use for to traverse and then one by one to assign an empty string, recommended to use (Object.assign)
Let's take a look at the basic usage of Object.assign.
The Object.assign method is used for merging objects. The first parameter (target object) can have the second and third parameters, both of which are source objects. All enumerable properties of the source object (source) are copied to the target object (target).
Const target = {target, source1, source2); const target = {target, source1, source2); console.log (target) / / {aVl1, bR2, cV3}
Note: the first parameter of the Object.assign method is the target object, and the following parameters are all source objects.
To get back to the point, sometimes the requirement encountered is that there are multiple input boxes, and each input box is v-modei bound with a corresponding value. When you click the reset button, you need to clear all the values in the input. In this case, you can use the Object.assign method. See the code for how to implement it.
Html code
Reset (empty input box)
Js code
Const values = {value1:'', value2:'', value3:'',} data () {return {valueData:Object.assign ({}, values)}}, methods: {/ / at this time, if you randomly enter a value in the input box, click the reset button, and you only need to re-copy it to valueData to clear the value in input. ToReset () {this.valueData = Object.assign ({}, values)}} vue null error problem
As shown in the above figure, the prompt percent is empty, and the web effect is as follows
If you don't want to bother in the self-test phase, just add data to the database or assign initial values to the initialization method. The easiest thing to do is to judge in vue template.
The code is as follows:
At this point, the study on "how vue assigns all the key in the object to null values" is over. I hope to be able to solve your 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.