建站服务外贸,网站开发如何报价单,wordpress 视频模板下载,开源的网站后台程序问题#xff1a;new Date()在安卓下正常#xff0c;在IOS下显示不出来。
原因#xff1a;在IOS下#xff0c;new Date(“2000-2-22 00:10”),返回的是undefined#xff0c;因为IOS不支持这种类型格式。
解决#xff1a;更换下格式#xff1a;new Date(“2000/2/22”) …问题new Date()在安卓下正常在IOS下显示不出来。
原因在IOS下new Date(“2000-2-22 00:10”),返回的是undefined因为IOS不支持这种类型格式。
解决更换下格式new Date(“2000/2/22”) 可以正常显示。
如果说确实要用到 new Date(“2000-2-22 00:10”) 这种格式的数据那么我们可以借助 date-fns 的JS库
npm install date-fnsimport { parse } from date-fnsasync goUseCardCoupon(item) {// 这里存在new Date()在IOS不生效的bug因而用到date-fns库const currentTime new Date()const startTime parse(item.start_time, yyyy-MM-dd HH:mm:ss, new Date())if (startTime currentTime) {this.$toast.fail(该卡券暂未生效请在有效使用时间内使用)return}
}