首页 > 其他分享 >element-ui的确认消息弹框校验;$prompt校验

element-ui的确认消息弹框校验;$prompt校验

时间:2023-02-28 09:56:05浏览次数:29  
标签:prompt log 校验 value 弹框 console message

this.$prompt('请输入您的姓名', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputPattern: /^.+$/,
          inputErrorMessage: '姓名为空'
        }).then(({ value }) => {
          this.$message({
            type: 'success',
            message: '你的姓名是: ' + value
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          });       
        });
 1 / this.$prompt的message前面加必填标志 *
 2       const h = this.$createElement
 3       this.$prompt(
 4         h('p', null, [h('i', { style: 'color: red' }, '* '),
 5           h('span', null, '请输入文件夹名称:')]),
 6         '提示',
 7         {
 8           confirmButtonText: '确定',
 9           cancelButtonText: '取消',
10           inputValue: '文件名',
11           // 非空验证方法1(函数)
12           // inputValidator: (value) => { // 点击按钮时,对文本框里面的值进行验证
13           //   if (!value) {
14           //     return '输入不能为空'
15           //   }
16           // },
17           // // 非空验证方法2(正则)
18           inputPattern: /^.+$/,
19           inputErrorMessage: '请输入内容。。。'
20           // callback:function(action, instance){
21           //     if(action === 'confirm'){
22           //         // do something...
23           //         console.log(instance.inputValue);
24           //     }
25           // }
26         }).then(({ value }) => {
27         console.log(value)
28         // TO DO DO ...
29       }).catch((err) => {
30         console.log(err)
31       })

 

标签:prompt,log,校验,value,弹框,console,message
From: https://www.cnblogs.com/HE0318bei/p/17162888.html

相关文章