其他分享
首页 > 其他分享> > 前端工作总结242-uni-提交成功加入表单验证

前端工作总结242-uni-提交成功加入表单验证

作者:互联网

增加验证规则
<u-form :model="form" :rules="rules" ref="uForm" :errorType="errorType">
			<navigator url="../LevineHua-editor/LevineHua-editor" class="single">
				<u-form-item label="荣誉照片" prop="container" label-width="150">
					<input placeholder="请输入荣誉照片" v-model="form.container" type="texarea" />
				</u-form-item>
			</navigator>
//提交
			submit() {
				//验证
				this.$refs.uForm.validate(valid => {
					if (valid) {
						this.form.marketId = this.vuex_user.market_id
						this.form.createdBy = this.vuex_user.name
						this.form.loginId = this.vuex_user.id
						//接口请求
						this.$u.api.getHonorAdd(this.form).then(res => {
							if (res.data.code == 200) {
								this.$refs.uToast.show({
									title: res.data.message,
									type: 'success',
									back: true
								})
							}else{
								this.$refs.uToast.show({
									title: res.data.message,
									type: 'error',
								})
							}
						})
					} else {
						console.log('验证失败')
					}
				})
			},

标签:vuex,form,res,refs,表单,user,242,uni,data
来源: https://www.cnblogs.com/yao-655442/p/16701548.html