element验证根据条件决定是否是必填项
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
示例:
<el-form-item label="删除工单任务:" prop="deleteSheetno" :rules="this.formData.businessType === '1040'?rules.deleteSheetno:[{ required: false, message: '请输入要删除的工单任务号', trigger: 'blur' }]">
<el-row class="demo-autocomplete">
<el-col :span="12">
<el-autocomplete
class="inline-input"
v-model="inputState"
:fetch-suggestions="querySearch"
placeholder="请输入或选择要删除的工单任务"
@select="handleSelectSheet"
></el-autocomplete>
</el-col>
</el-row>
</el-form-item>
其实关键代码只有绑定的rule;如下::rules=“this.formData.businessType === ‘1040’?rules.deleteSheetno:[{ required: false, message: ‘请输入要删除的工单任务号’, trigger: ‘blur’ }]”,这里的值this.formData.businessType === ‘1040’,可根据是字符串或者数字决定等于什么或者不等于什么;如果等于,就是必填的,如果不等于,那就不是必填的。
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 个月前
更多推荐
已为社区贡献2条内容
所有评论(0)