当前位置:网站首页>表单自定义校验规则
表单自定义校验规则
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()中通过返回的结果来判断执行校验函数中的哪一步,并执行回调函数。
完成之后就可以进行表单验证了。
边栏推荐
- 2022-2028 global human internal visualization system industry research and trend analysis report
- [question 008: what is UV in unity?]
- 图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
- About DNS
- Mongodb base de données non relationnelle
- How to run oddish successfully from 0?
- 2022 safety officer-c certificate examination questions and mock examination
- QT实现界面跳转
- [learn C and fly] 2day Chapter 8 pointer (practice 8.1 password unlocking)
- 自定义组件的 v-model
猜你喜欢

Leetcode question brushing (10) - sequential question brushing 46 to 50
![[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)](/img/e0/05890eafdb291c5aaff78cc241f455.jpg)
[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)

只需简单几步 - 开始玩耍微信小程序

图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证

Analysis of FLV packaging format

Cache processing scheme in high concurrency scenario

Discussion on related configuration of thread pool

MongoDB非关系型数据库

Force deduction daily question 540 A single element in an ordered array
![[reading notes] programmer training manual - practical learning is the most effective (project driven)](/img/13/28116a74512895ad725dffed02f8bd.png)
[reading notes] programmer training manual - practical learning is the most effective (project driven)
随机推荐
What is the function of the headphone driver
2022-2028 global soft capsule manufacturing machine industry research and trend analysis report
Qualcomm platform WiFi -- Native crash caused by WiFi
Use usedeferredvalue for asynchronous rendering
2022-2028 global deep sea generator controller industry research and trend analysis report
Possible causes of runtime error
Feature query of hypergraph iserver rest Service
2022-2028 global human internal visualization system industry research and trend analysis report
Es interview questions
2022-2028 global wood vacuum coating machine industry research and trend analysis report
Jvm-01 (phased learning)
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
Basic 01: print string
About DNS
The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
2022 safety officer-c certificate examination questions and mock examination
连通块模板及变式(共4题)
tarjan2
QT使用sqllite
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)