element单独检验form表单中的一项

<el-form-item prop="limitDays" style="margin-left: 5px;">
  <el-input v-model="ruleForm.limitDays" placeholder="天数" style="width: 100px;" />
el-form-item>
<el-form-item prop="limitCount">
  <el-input v-model="ruleForm.limitCount" placeholder="个数" style="width: 100px;" />
el-form-item>

<el-button type="primary" link @click="clickBtn(ruleFormRef)">生成图文详情el-button>
const clickBtn = async (formEl: FormInstance | undefined ) => {
  if (!formEl) return
  await formEl.validateField(['limitDays', 'limitCount'], (flag) => {
      if (flag) {
		console.log('验证')
      }
  })
}

你可能感兴趣的:(javascript,前端,vue.js)