admin 发表于 2025-9-27 10:12:15

uts写法


/**
* 接口地址
* 替换为自己的url域名
*/
export const interfaceUrl = ():void => {
        return apiUrl
}

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

/**
* @param string title modal框标题文字
* @param string content moddal框提示内容
* @param bool showCancel 是否显示取消按钮
* @param function callback 回调函数
* @param string confirmColor 确定按钮的颜色,默认是:#5677fc
* @param string confirmText 确定按钮的文字,默认是:确定
*/
export const modal = (): void => {
        uni.showModal({
                title: title || '提示',
                content: content,
                showCancel: showCancel,
                cancelColor: "#555",
                confirmColor: confirmColor || "#5677fc",
                confirmText: confirmText || "确定",
                success(res) {
                        if (res.confirm) {
                                callback && callback(true)
                        } else {
                                callback && callback(false)
                        }
                }
        })
}


页: [1]
查看完整版本: uts写法