uniapp常用提示框uni.showToast
记录一下开发经常会用到的几种提示框
前端代码里最常用的
官方参考文档:https://uniapp.dcloud.io/api/ui/prompt?id=showtoast
1:成功提示
提交表单的时候,如果提交成功
uni.showToast({ title: '提交成功', duration: 2000 });
![](http://upload-images.jianshu.io/upload_images/5640239-3650c17c09d640ff.png?imageMogr2/auto-orient/strip|imageView2/2/w/122/format/webp)
2:加载框
uni.showLoading({ title: '加载中' }); setTimeout(function () { uni.hideLoading(); }, 2000);
![](http://upload-images.jianshu.io/upload_images/5640239-5a779942458bf063.png?imageMogr2/auto-orient/strip|imageView2/2/w/144/format/webp)
3:去掉图标,只显示文字
uni.showToast({ title: '请填写员工工号', icon:'none', duration: 2000 });
![](http://upload-images.jianshu.io/upload_images/5640239-4a9d772c73bd5def.png?imageMogr2/auto-orient/strip|imageView2/2/w/407/format/webp)
4:模态弹窗
uni.showModal({ title: '提示', content: '这是一个模态弹窗', success: function (res) { if (res.confirm) { console.log('用户点击确定'); } else if (res.cancel) { console.log('用户点击取消'); } } });
![](https://upload-images.jianshu.io/upload_images/5640239-28a5586721e78be0.png?imageMogr2/auto-orient/strip|imageView2/2/w/468/format/webp)
作者:祈澈菇凉
链接:https://www.jianshu.com/p/2f59fa8d40f0
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。