当前位置:网站首页>表单自定义校验规则
表单自定义校验规则
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 military computer industry research and trend analysis report
- What are the common proxy servers and what are the differences?
- Vsocde has cli every time it is opened js
- Mathematics in Sinorgchem: computational geometry
- Stdref and stdcref
- Discussion on related configuration of thread pool
- QT uses sqllite
- tarjan2
- Learning notes of software testing -- theoretical knowledge of software testing
- How to turn off the LED light of Rog motherboard
猜你喜欢

Mmsegmentation series training and reasoning their own data set (3)
![[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table](/img/f4/298f64c4b4f8674eda4e8fb19a976a.png)
[learn C and fly] 4day Chapter 2 program in C language (exercise 2.5 generate power table and factorial table

Start a business

CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决

GB/T-2423. XX environmental test documents, including the latest documents

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

Mongodb non relational database
![[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)](/img/96/8c4baa1dd8e35e2cab67461e7c447b.jpg)
[staff] diacritical mark (ascending sign | descending sign B | double ascending sign x | double descending sign BB)

Multi threaded query, double efficiency

How to develop digital collections? How to develop your own digital collections
随机推荐
[staff] restore mark (Introduction to the use of restore mark | example analysis of Metaphone mark and restore mark)
How to develop digital collections? How to develop your own digital collections
Software testing learning notes - network knowledge
[staff] pitch representation (bass clef | C1 36 note pitch representation | C2 48 note pitch representation | C3 60 note pitch representation)
Possible causes of runtime error
Pychart creates new projects & loads faster & fonts larger & changes appearance
Baohong industry | what misunderstandings should we pay attention to when diversifying investment
CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
2022-2028 global manual dental cleaning equipment industry research and trend analysis report
3124. Word list
Soul app released the annual report on generation Z behavior: nearly 20% of young people love shopping in the vegetable market
2022-2028 global encryption software industry research and trend analysis report
Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
Batch detect whether there is CDN in URL - high accuracy
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
2022安全员-C证考试题及模拟考试
What are the characteristics of common web proxy IP
Es interview questions
2022-2028 global military computer industry research and trend analysis report
2022 hoisting machinery command examination paper and summary of hoisting machinery command examination