Form verification method and system based on vue.js
A verification method and form technology, applied in the verification field, can solve problems such as insufficient reusability, and achieve the effect of maintaining scalability, easy maintenance, and improving development efficiency
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0091] Please refer to figure 2 , Embodiment one of the present invention is: a kind of form verification method, described method is based on the open source framework of Vue.js, comprises the following steps:
[0092] S101: Create a form element component; specifically, use the componentization feature of Vue.js to create a form element component.
[0093] S102: Preset verification rule information corresponding to the form element component; the verification rule may be a necessity verification, a length limit verification, a null verification, and the like.
[0094] S103: Determine whether the input value of a form element component has changed, and if so, execute step S104. The reason for the change may be due to user re-entry or other means.
[0095] S104: Verify the input value of the form element component according to the verification rule information corresponding to the form element component.
[0096] S105: Determine whether the input value conforms to the veri...
Embodiment 2
[0102] This embodiment is a further extension of Embodiment 1.
[0103] Such as image 3 As shown, after the form element component is created in step S101, the following steps are also included:
[0104] S201: Create a form container component and a form element adapter; specifically, also use the componentization feature of Vue.js to create. Among them, the form easy component provides two attribute input parameters, one is the configuration information parameter, and the required form element component is rendered according to the parameter information, such as error message, form element type name, etc., and can also include preset verification rule information; The other is the form initial data parameter, which is used to restore and display the saved form data.
[0105] S202: Register the form element component with the form container component through the form element adapter. The form element adapter uses the is attribute that comes with vue.js to dynamically rende...
Embodiment 3
[0121] This embodiment is a specific application scenario of the foregoing embodiments.
[0122] Based on the open source framework of Vue.js, create and register a form validation plug-in, which will identify a certain form container component through the validator attribute, and traverse all form element components under the form container component from top to bottom, in the init life of the component Periodically register a $validate method and $validation attribute for each form element component, and $validation is used to store the verification result.
[0123] Create a CFormCell component, that is, a form element adapter. The content of this component uses a component component with an is attribute, plus a span tag for displaying error information. The specific form element type is passed in from the outside, and the component component instantiates the specific component according to the type.
[0124] Create the CForm.vue component, which is the form container compo...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


