element中input提交时提示input不能为空
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
最近根据需求完成表单提交按钮(方便自己以后使用)
只有代码
首先表单prop,ref 都要保持一致
<el-form :model="form" ref="formData" :rules="rules">
<el-form-item label="实际停电时长" :label-width="formLabelWidth" prop="powerCutTimeActual">
<el-input v-model="form.powerCutTimeActual" autocomplete="off" required="required"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
el-button @click="dialogFormVisible = false">取 消</el-button>
<el-button type="primary" @click="submitIsPower('formData')" :validate-event="false">确 定</el-button>
</div>```
```javascript
form: {
powerCutTimeActual: ''
},
rules: {
powerCutTimeActual: [
{ required: true, message: '实际停电时长不能为空'},
]
},
第三步
submitIsPower(formData) {
this.$refs[formData].validate((valid) => {
if (valid) {
}
})
},
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45
7 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)