当前位置:网站首页>表单自定义校验规则
表单自定义校验规则
2022-07-02 03:00:00 【飞奔的马铃猫】
表单自定义校验规则
在看vue-element-admin时了解到了 element中的自定义校验规则。在这里记录一下。
直接开始,要实现功能,需要实现以下几点 绑定表单,和实现验证规则
1.完成表单和规则的绑定
表单:
在 el-from 整体中绑定对每一个表单的规则,
并且为每一个表单 item 绑定 prop 用于判断使用哪个验证规则

这里是定义了规则。
表单中的prop和这里的对应,
可以看到其中有 validator 这一项。后面是定义的方法
2.完成校验函数的定义

这个校验函数需要定义在 data 的非return 中
函数组成:

其中 value 和 callback 使用的最多
解释一下我的代码:
validUsername.js:
将进行校验时,将value的值,传入validUsername()中通过返回的结果来判断执行校验函数中的哪一步,并执行回调函数。
完成之后就可以进行表单验证了。
边栏推荐
- Provincial election + noi Part IV graph theory
- [learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table
- Software testing learning notes - network knowledge
- 离婚3年以发现尚未分割的共同财产,还可以要么
- Pychart creates new projects & loads faster & fonts larger & changes appearance
- 2022-2028 global aluminum beverage can coating industry research and trend analysis report
- 使用 useDeferredValue 进行异步渲染
- 旋转框目标检测mmrotate v0.3.1 学习模型
- Feature query of hypergraph iserver rest Service
- Mmsegmentation series training and reasoning their own data set (3)
猜你喜欢
Face++ realizes face detection in the way of flow

连通块模板及变式(共4题)

Which kind of sports headphones is easier to use? The most recommended sports headphones
![[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials](/img/ae/7edbdf55795400166650c795c8bd58.jpg)
[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials
![[JVM] detailed description of the process of creating objects](/img/6e/0803b6b63c48337985faae8d5cbe1a.png)
[JVM] detailed description of the process of creating objects

批量检测url是否存在cdn—高准确率

Baohong industry | 6 financial management models at different stages of life
![[staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the](/img/fe/d97b25f702bbc05f941d08147259e0.jpg)
[staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the

MVVM and MVC

2022-2028 global aluminum beverage can coating industry research and trend analysis report
随机推荐
4. Find the median of two positive arrays
QT uses sqllite
QT实现界面跳转
2022-2028 global military computer industry research and trend analysis report
How does proxy IP participate in the direct battle between web crawlers and anti crawlers
About DNS
Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]
Use usedeferredvalue for asynchronous rendering
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
Basic 01: print string
2022 low voltage electrician test question simulation test question bank simulation test platform operation
[learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
使用 useDeferredValue 进行异步渲染
How to create an instance of the control defined in SAP ui5 XML view at runtime?
使用开源项目【Banner】实现轮播图效果(带小圆点)
Unit · elementary C # learning notes
小米青年工程师,本来只是去打个酱油
自定义组件的 v-model
Après le mariage
CVPR 2022 | Dalian Institute of technology proposes a self calibration lighting framework for low light level image enhancement of real scenes