Vue Element UI 消息提示框


 1 this.$prompt('Reason:', 'To Operation Agent', {
 2                     showCancelButton: true,
 3                     showInput: true,
 4                     inputType: 'textarea',
 5                     inputValue: "",
 6                     inputValidator: value => {
 7                         if (value === "") {
 8                             return true;
 9                         }
10                         return !(value.length > 10);
11                     },
12                     inputErrorMessage: 'input maxLength is 10!',
13                     beforeClose:(action, instance, done)=> {
14                         if (action==='confirm'){
15                             alert("1111");
16                         }
17                         done();
18 
19                     }
20                 }).then(() => {
21                     this.$message({
22                         type: 'success',
23                         message: '已駁回'
24                     });
25                 }).catch(() => {
26                     this.$message({
27                         type: 'info',
28                         message: '已取消'
29                     });
30                 });

介紹:使用Vue Element UI 封裝的MessageBox的提示框

主要功能:

1:可輸入文字的提示框(textarea):inputType: 'textarea',

2:有校驗和校驗提示:inputValidator和inputErrorMessage

3:點擊消息提示框的確認按鈕前可添加自己的操作:beforeClose

4:beforeClose中一定在自定義操作結束后添加done()方法,保證按鈕操作能正常結束

拓展:

1:提示框還有:text,password和number類型

2:如果在BeforeClose中不指定action===confirm,則頁面的X和取消,確認按鈕都會觸發BeforeClose里面的操作,

action===confirm:只有確認按鈕觸發

action!=confirm:只有X和取消按鈕觸發

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM