這篇文章較早,參考時請優先查看官方文檔API 和 源碼
Mint-UI 的Message Box 是prompt類型時,可以添加正則判斷或者function判斷條件。具體可以查看Mint-UI源碼。
添加正則判斷條件:
MessageBox({ $type:'prompt', title:'輸入驗證碼', message:'請填寫您收到的驗證碼', closeOnClickModal:false, //點擊model背景層不關閉MessageBox showCancelButton:false, //不顯示取消按鈕 inputPattern:/^[a-zA-Z0-9]{6}$/, //正則條件 inputErrorMessage:'請輸入正確的驗證碼', showInput:true }).then(({ value, action }) => { /* value 為填寫的值,進行下一步操作*/ console.log(value); });
添加function判斷條件
MessageBox({ $type:'prompt', title:'輸入驗證碼', message:'請填寫您收到的驗證碼', closeOnClickModal:false, //點擊model背景層不關閉MessageBox showCancelButton:false, //不顯示取消按鈕 inputValidator:function(v){return /^[a-zA-Z0-9]{6}$/.test(v);}, //function可以用來寫更復雜的判斷條件,返回布爾值 inputErrorMessage:'請輸入正確的驗證碼', showInput:true }).then(({ value, action }) => { /* value 為填寫的值,進行下一步操作 */ console.log(value); });