showModal
// 封装提示框
export const showModal = (content, showCancel = false, title = "提示") => {
return new Promise((resolve, reject) => {
uni.showModal({
title: title,
content: content,
showCancel: showCancel,
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
},
});
});
};
showToast
// 封装showToast
export const showToast = (content, icon = "none") => {
return new Promise((resolve, reject) => {
uni.showToast({
title: content,
icon: icon,
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
},
});
});
};
showLoading
// 封装showLoading
export const showLoading = (content, mask = true) => {
return new Promise((resolve, reject) => {
uni.showLoading({
title: content,
mask: mask,
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
},
});
});
};
页面内使用,引入
import { showModal, showToast, showLoading } from "@/js/common.js";
showModal('1111');
showToast("保存成功");
showLoading("加载中");