消息窗口( Messager )提供不同樣式的消息窗口,如警示( alert )、確認(rèn)( confirm )等。 消息窗口( Messager )都是異步的。用戶可以在與消息窗口交互后使用回調(diào)函數(shù)以完成一些動作。
名稱 | 數(shù)據(jù)類型 | 作用描述 | 默認(rèn)值 |
---|---|---|---|
ok | string | 確定按鈕文本。 | Ok |
cancel | string | 取消按鈕文本。 | Cancel |
title | string | 消息標(biāo)題。 | |
msg | string | 要在對話框中顯示的消息。 | |
icon | string | 要在對話框上顯示的圖標(biāo)類。 |
名稱 | 參數(shù) | 返回值 | 作用描述 |
---|---|---|---|
alert | options | void | 顯示警告消息對話框。 |
confirm | options | void | 顯示確認(rèn)消息對話框。 |
prompt | options | void | 顯示提示消息對話框。 |
alert
方法代碼實(shí)例:this.$messager.alert({
title: "Info",
icon: "info",
msg: "Here is a info message!"
});
confirm
方法代碼實(shí)例:this.$messager.confirm({
title: "Confirm",
msg: "Are you confirm this?",
result: r => {
if (r) {
alert("confirmed: " + r);
}
}
});
prompt
方法代碼實(shí)例:this.$messager.prompt({
title: "Prompt",
msg: "Please type something",
result: r => {
if (r) {
alert("you type: " + r);
}
}
});
注:
- 繼承: None 。
更多建議: