uniapp封装函数的方法:1、获取当前时间,代码为【hour = date.getHours()
本教程操作环境:windows7系统、uni-app2.5.1版本,该方法适用于所有品牌电脑。
推荐(免费):uni-app开发教程
uniapp封装函数的方法:
获取当前时间,格式YYYY-MM-DD HH:MM:SS
const GetNowTime = time => { var date = time, year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(), minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(), second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); month >= 1 && month <= 9 ? (month = "0" + month) : ""; day >= 0 && day <= 9 ? (day = "0" + day) : ""; var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; return timer; }登录后复制格式化电话号码
const GetPhone = phone => { let tel = phone.slice(0, 3) + '****' + phone.slice(7, 11); return tel; } module.exports = { GetNowTime, GetPhone }登录后复制
以上就是uniapp如何封装函数的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号