之前写都没有记录,今天记录一下,文档上没有写的关于$prompt内容提交校验

1.inputType 输入框的类型 默认text,  文档比较简洁没有列举其他的type其实inputtype有很多,比如filedate比如这里我写的textarea也是OK的 ;

2.inputValidator  输入框的校验函数。可以返回布尔值字符串,若返回一个字符串, 则返回结果会被赋值inputErrorMessage比如

inputValidator  :(val) => { if(!val)return ‘放弃原因必填‘},

//如上图输入必填校验用inputValidator 或者 inputPattern可以

this.$prompt('请填写放弃原因', '放弃接单', {
  confirmButtonText: '确定',
  cancelButtonText: '取消',
  inputType: 'textarea',

 // inputValidator: (val) => { if(!val)return '放弃原因必填'},

  inputPattern: /^.+$/,

  inputErrorMessage: '放弃原因必填'
 }).then(({ value }) => {
  
         
 }).catch(() => {});

 

 

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注