我想把圖中紅色框轉(zhuǎn)為多少天前如下方法<script>? ? function replyTime(value) {? ? ? ? if (!value) {? ? ? ? ? ? return ''? ? ? ? }? ? ? ? let date = new Date(value)? ? ? ? let time = new Date().getTime() - date.getTime() // 現(xiàn)在的時(shí)間-傳入的時(shí)間 = 相差的時(shí)間(單位 = 毫秒)? ? ? ? if (time < 0) {? ? ? ? ? ? return ''? ? ? ? } else if ((time / 1000 < 30)) {? ? ? ? ? ? return '剛剛'? ? ? ? } else if (time / 1000 < 60) {? ? ? ? ? ? return parseInt((time / 1000)) + '秒前'? ? ? ? } else if ((time / 60000) < 60) {? ? ? ? ? ? return parseInt((time / 60000)) + '分鐘前'? ? ? ? } else if ((time / 3600000) < 24) {? ? ? ? ? ? return parseInt(time / 3600000) + '小時(shí)前'? ? ? ? } else if ((time / 86400000) < 31) {? ? ? ? ? ? return parseInt(time / 86400000) + '天前'? ? ? ? } else if ((time / 2592000000) < 12) {? ? ? ? ? ? return parseInt(time / 2592000000) + '月前'? ? ? ? } else {? ? ? ? ? ? return parseInt(time / 31536000000) + '年前'? ? ? ? }? ? }? ? console.log(replyTime('2018-04-26T09:51:19.808Z'))? //22前天</script>空白,也不報(bào)錯(cuò)重新上傳
小程序,怎么給數(shù)據(jù)渲染時(shí)加一個(gè)方法,改變他的值,如下圖和代碼
暮色呼如
2019-03-22 19:15:36