当前位置:网站首页>表单自定义校验规则
表单自定义校验规则
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()中通过返回的结果来判断执行校验函数中的哪一步,并执行回调函数。
完成之后就可以进行表单验证了。
边栏推荐
- PMP personal sprint preparation experience
- 2022-2028 global encryption software industry research and trend analysis report
- Formatting logic of SAP ui5 currency amount display
- 結婚後
- 超图iServer rest服务之feature查询
- CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
- [untitled]
- Software testing learning notes - network knowledge
- How to create an instance of the control defined in SAP ui5 XML view at runtime?
- Use usedeferredvalue for asynchronous rendering
猜你喜欢
Which brand of running headphones is good? How many professional running headphones are recommended
After marriage
创业了...
2022-2028 global aluminum beverage can coating industry research and trend analysis report
超图iServer rest服务之feature查询
Xiaomi, a young engineer, was just going to make soy sauce
PHP notes - use Smarty to set public pages (include, if, else, variable settings)
2022-2028 global human internal visualization system industry research and trend analysis report
Baohong industry | four basic knowledge necessary for personal finance
Leetcode question brushing (10) - sequential question brushing 46 to 50
随机推荐
Yyds dry goods inventory accelerating vacuum in PG
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)
【无标题】
LFM signal denoising, time-frequency analysis, filtering
New programmer magazine | Li Penghui talks about open source cloud native message flow system
Share the basic knowledge of a common Hongmeng application
小米青年工程师,本来只是去打个酱油
Discussion on related configuration of thread pool
浅谈线程池相关配置
2022-2028 global military computer industry research and trend analysis report
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
2022低压电工考试题模拟考试题库模拟考试平台操作
The capacity is upgraded again, and the new 256gb large capacity specification of Lexar rexa 2000x memory card is added
PMP personal sprint preparation experience
結婚後
Provincial election + noi Part IV graph theory
多线程查询,效率翻倍
2022-2028 global encryption software industry research and trend analysis report
高并发场景下缓存处理方案
Connected block template and variants (4 questions in total)