当前位置:网站首页>表单自定义校验规则
表单自定义校验规则
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()中通过返回的结果来判断执行校验函数中的哪一步,并执行回调函数。
完成之后就可以进行表单验证了。
边栏推荐
- Divorce for 3 years to discover the undivided joint property, or
- MongoDB非关系型数据库
- 2022-2028 global deep sea generator controller industry research and trend analysis report
- Baohong industry | what misunderstandings should we pay attention to when diversifying investment
- LFM signal denoising, time-frequency analysis, filtering
- Use the open source project [banner] to achieve the effect of rotating pictures (with dots)
- Query word weight, search word weight calculation
- Es interview questions
- 2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
- 连通块模板及变式(共4题)
猜你喜欢

多线程查询,效率翻倍

Baohong industry | what misunderstandings should we pay attention to when diversifying investment

Remote connection to MySQL under windows and Linux system

2022-2028 global nano abrasive industry research and trend analysis report
![[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)](/img/8e/a86a9724251718d98ce172a6a96e53.png)
[learn C and fly] 3day Chapter 2 program in C language (exercise 2.3 calculate piecewise functions)
![寻找重复数[抽象二分/快慢指针/二进制枚举]](/img/9b/3c001c3b86ca3f8622daa7f7687cdb.png)
寻找重复数[抽象二分/快慢指针/二进制枚举]

Après le mariage

GB/T-2423.xx 环境试验文件,整理包括了最新的文件里面
![[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)](/img/39/42b1726e5f446f126a42d7ac673dce.png)
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)

批量检测url是否存在cdn—高准确率
随机推荐
Oracle creates a user with read-only permission in four simple steps
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)
What is the function of the headphone driver
New programmer magazine | Li Penghui talks about open source cloud native message flow system
CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
2022-2028 global nano abrasive industry research and trend analysis report
结婚后
Discussion on related configuration of thread pool
Set status bar color
es面試題
2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
C # use system data. The split mixed mode assembly is generated for the "v2.0.50727" version of the runtime, and it cannot be loaded in the 4.0 runtime without configuring other information
Multi threaded query, double efficiency
[staff] pitch representation (treble clef | C3 60 ~ B3 71 pitch representation | C4 72 pitch representation | C5 84 pitch representation)
Provincial election + noi Part IV graph theory
Mmsegmentation series training and reasoning their own data set (3)
Kibana controls es
Leetcode question brushing (10) - sequential question brushing 46 to 50
The capacity is upgraded again, and the new 256gb large capacity specification of Lexar rexa 2000x memory card is added
V-model of custom component