65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
vant.Toast.allowMultiple();
|
|
|
|
const modal = {
|
|
// 消息提示
|
|
msg(content) {
|
|
vant.Toast(content)
|
|
},
|
|
// 错误消息
|
|
msgError(content) {
|
|
vant.Toast.fail(content)
|
|
},
|
|
// 成功消息
|
|
msgSuccess(content) {
|
|
vant.Toast.success(content)
|
|
},
|
|
// 弹出提示
|
|
alert(content) {
|
|
vant.Dialog.alert({
|
|
title: '提示',
|
|
message: content
|
|
}).then(() => {
|
|
// on close
|
|
});
|
|
},
|
|
// 确认窗体
|
|
confirm(content) {
|
|
return new Promise((resolve, reject) => {
|
|
vant.Dialog.confirm({
|
|
title: '提示',
|
|
message: content,
|
|
}).then(() => {
|
|
resolve()
|
|
}).catch(() => {
|
|
// reject()
|
|
})
|
|
})
|
|
},
|
|
// 提示信息
|
|
showToast(option) {
|
|
if (typeof option === "object") {
|
|
vant.Toast(option)
|
|
} else {
|
|
vant.Toast.loading({
|
|
message: option,
|
|
forbidClick: true,
|
|
loadingType: 'spinner',
|
|
duration: 2500
|
|
});
|
|
}
|
|
},
|
|
// 打开遮罩层
|
|
loading(content) {
|
|
vant.Toast.loading({
|
|
message: content,
|
|
forbidClick: true,
|
|
overlay: true,
|
|
duration: 0
|
|
});
|
|
},
|
|
// 关闭遮罩层
|
|
closeLoading() {
|
|
vant.Toast.clear();
|
|
}
|
|
}
|
|
Vue.prototype.$modal = modal |