mintUI之MessageBox表单验证

<div class="mobileTrainActivityDetailButton_css">
	<mt-button v-if="path=='/mobileMyTrains'?true:false" @click.native="leave" size="large"> 请假 </mt-button>
</div>

//方法体里面
leave() {
   MessageBox.prompt('请假理由', { inputValidator: (val) => { if (val === null) {    return true;//初始化的值为null,不做处理的话,刚打开MessageBox就会校验出错,影响用户体验 } return !(val.length < 100)   }, inputErrorMessage: '不能小于100字' }).then((val) => { this.loading = true; var leaveForm = { trainId: this.trainInfo.trainId, leaveFlow: this.trainInfo.leaveFlow, leaveReason: val, }; this.postRequest("/tmsproxy/trainLeave", leaveForm).then(resp => { this.loading = false; if(resp.data.status == "success") { MessageBox.alert(resp.data.msg, ""); } }) }, () => { console.info('cancel') }) }

  

posted @ 2019-04-23 16:44  十黎九夏  阅读(2419)  评论(0编辑  收藏  举报