新做uni項目,記錄一下常用的方法
官方參考文檔:https://uniapp.dcloud.io/api/ui/prompt?id=showtoast
1:成功提示
提交表單的時候,如果提交成功
uni.showToast({
title: '提交成功',
duration: 2000
});
2:加載框
uni.showLoading({
title: '加載中'
});
setTimeout(function () {
uni.hideLoading();
}, 2000);
3:去掉圖標,只顯示文字
uni.showToast({
title: '請填寫員工工號',
icon:'none',
duration: 2000
});
4:模態彈窗
uni.showModal({
title: '提示',
content: '這是一個模態彈窗',
success: function (res) {
if (res.confirm) {
console.log('用戶點擊確定');
} else if (res.cancel) {
console.log('用戶點擊取消');
}
}
});