1. form表單驗證,提示信息,為后端返回的信息
Element UI 經常使用的表單驗證 rule 好像實現不了,查詢了其他的解決辦法,使用了Element UI 提供的另一個屬性 error
<el-form :model="dataForm" ref="dataForm" label-width="110px" >
<el-form-item label="客戶登錄賬號:" :label-position="'left'" :error="dataForm.errorMsg">
<el-input class="minH" type="text" v-model="dataForm.userid">
</el-input>
</el-form-item>
里面的:error="dataForm.errorMsg" 默認為null
dataForm: {
id: '',
userid:'',
// code: '',
remarks: '',
// acceptFeedback: '',
status: '',
errorMsg:null
},
表單驗證提示信息,直接設定為后端返回的信息
let self = this this.$http.post(`${window.SITE_CONFIG['baseURL']}/inquiry/inquirysheet/save`, params) .then(_data => { if (_data.result.code === -1) { self.dataForm.errorMsg = _data.result.msg this.buttonLoading = false } else if (this.dataForm.userid === '') { self.dataForm.errorMsg = "登錄賬號不能為空" this.buttonLoading = false }
顯示效果如下: