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

2023-03-07,,

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 })

element-ui的确认消息弹框校验;$prompt校验的相关教程结束。

《element-ui的确认消息弹框校验;$prompt校验.doc》

下载本文的Word格式文档,以方便收藏与打印。