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 focuses on "how to verify the parameters of vue.js components", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to check the parameters of vue.js components".
1. What is component parameter verification?
What is component parameter verification? Generally speaking, when we program, the parent component passes some parameters to the child component, then the child component verifies the data, which is called component parameter verification. The following is the code related to the verification:
Vue.component ('child', {props: {content:String}, template:' {{content}'}) var vm = new Vue ({el:'#root'})
The parent component must be passed to the child component as a string.
Check method: we call it an object through the props definition we receive, and specify the type, but not as an array; we can accept either a string type or an array type. The code is as follows:
Props: {content: [String, Number]}
two。 Complex check
For complex checks, let's take a look at this string of code:
Vue.component ('child', {props: {content: {whether the type:String,// data type required:false,// is required default:'default content',// if no value is passed The default value is validator:function (val) {/ / Custom verifier. Data must be > 5 return (val.length > 5)}}, template:' {{content}}'}) var vm = new Vue ({el:'#root'})
We know that when the parent component of the props property passes a parameter to the child component, if the child component happens to declare this parameter, it will receive On the contrary, if the parent component of the non-props property passes parameters to the child component, and there is no props in the child component, it will report an error and will not receive it, so we cannot use this content. The second feature is that the child component does not receive, the corresponding attribute value will be displayed in the tag, and the props property will not be displayed.
At this point, I believe you have a deeper understanding of "how to verify vue.js component parameters". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.