微信小程序字符串方法replaceAll有bug,在发布版上字符串没有这个方法
computed: {
canApply: function () {
const { detail } = this
if (detail && detail.create_time) {
console.info('detail', detail.create_time)
const create_time = new Date(detail.create_time.replaceAll('-', '/')).getTime()
if ((Date.now() - create_time) > 1000 * 60 * 60 * 24 * 7) {
return false
}
return true
}
return false
}
}
s上面这段代码报replaceAll is not function,将const create_time = new Date(detail.create_time.replaceAll('-', '/')).getTime()换成
const create_time = new Date(detail.create_time.replace(/-/g, '/')).getTime()就可以了,小程序基础库2.14.4,
是不是小程序不支持字符串的replaceAll方法啊