若依前端分离版-APP(UNI APP)表单添加验证

1.在page页面中onReady事件添加如下代码

复制代码
		onReady() {
			this.$refs.form.setRules(this.rules)
		},

2.在data中添加ruels这个对象

复制代码
				rules: {
					nickName: {
						rules: [{
							required: true,
							errorMessage: '用户昵称不能为空'
						}]
					},
					phonenumber: {
						rules: [{
							required: true,
							errorMessage: '手机号码不能为空'
						}, {
							pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
							errorMessage: '请输入正确的手机号码'
						}]
					},
					email: {
						rules: [{
							required: true,
							errorMessage: '邮箱地址不能为空'
						}, {
							format: 'email',
							errorMessage: '请输入正确的邮箱地址'
						}]
					}
				},
复制代码
			/** 提交按钮 保存报工按钮 */
			submitForm(ref) {
				console.log("保存调度派工开始")
				this.$refs.form.validate().then(res => {
						if (this.repair.repairId != null) {
							updateRepair(this.form).then(response => {
								this.$modal.msgSuccess("修改成功");
								this.open = false;
								this.getList();

							});
						} else {
							addRepair(this.repair).then(response => {
								this.$modal.msgSuccess("新增成功");
								this.open = false;
							});
						}
					}
				);
				console.log("保存调度派工结束")
			},

注:得到用户存储的帐号和密码

复制代码
		userName: this.$store.state.user.name,
相关推荐
拆房老料36 分钟前
【第四部分:Agentic 智能体设计模式】16. 一个 Prompt 搞不定复杂任务?试试 Prompt Chaining
java·前端·人工智能·设计模式·prompt
曹牧6 小时前
C#:空合并运算符
java·前端·数据库
小羊没烦恼!7 小时前
铁道部新客票系统设计(二)
开发语言·前端·数据库·python·oracle·c#·php
智能直播9 小时前
RK3518:1.5G 内存 + 8G 存储,如何跑起硬件编解码、Web、AI 识别、绿幕特效
前端·人工智能·5g
掘金酱10 小时前
【10.24 特别活动】AI 时代,程序员的新饭碗在哪里?
前端·人工智能·后端
excel11 小时前
多进程环境下使用 PM2 部署 Socket.IO:需要注意什么
前端
IT_陈寒11 小时前
Redis的原子性竟然失效了?记一次分布式锁翻车实录
前端·人工智能·后端
时间的情敌12 小时前
《回顾 2018 前端:Vue2 成熟期,Webpack4 发布,PWA 大火》
前端
Java后端的Ai之路13 小时前
前端技术Vue-09-webpack-vuejs-实战
前端·vue.js·webpack
LMT流氓兔13 小时前
第五单元——第4课:给工具参数加校验
java·前端·算法·ai·langchain