查看: 358|回复: 0

uts写法

[复制链接]

748

主题

39

回帖

3907

积分

管理员

总舵主

积分
3907
QQ
发表于 2025-9-27 10:12:15 | 显示全部楼层 |阅读模式

  1. /**
  2. * 接口地址
  3. * 替换为自己的url域名
  4. */
  5. export const interfaceUrl = ():void => {
  6.         return apiUrl
  7. }

  8. /**
  9. * @param string text toast提示文字
  10. * @param number duration 默认:2000毫秒
  11. * @param bool success 值为true带成功图标,否则无图标
  12. */
  13. export const toast = (text:string, success:boolean = false):void => {
  14.         uni.showToast({
  15.                 title: text || "出错啦~",
  16.                 icon: success ? 'success' : 'none'
  17.         })
  18. }

  19. /**
  20. * @param string title modal框标题文字
  21. * @param string content moddal框提示内容
  22. * @param bool showCancel 是否显示取消按钮
  23. * @param function callback 回调函数
  24. * @param string confirmColor 确定按钮的颜色,默认是:#5677fc
  25. * @param string confirmText 确定按钮的文字,默认是:确定
  26. */
  27. export const modal = (): void => {
  28.         uni.showModal({
  29.                 title: title || '提示',
  30.                 content: content,
  31.                 showCancel: showCancel,
  32.                 cancelColor: "#555",
  33.                 confirmColor: confirmColor || "#5677fc",
  34.                 confirmText: confirmText || "确定",
  35.                 success(res) {
  36.                         if (res.confirm) {
  37.                                 callback && callback(true)
  38.                         } else {
  39.                                 callback && callback(false)
  40.                         }
  41.                 }
  42.         })
  43. }
复制代码


道不同,不相为谋!理想要有,万一实现了呢?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:2513533699@qq.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|鲁ICP备19000917号|鲁公网安备37078302000320号

在本版发帖
关注公众号
QQ客服返回顶部