Vue v-for takes a timestamp, adds a filter, and becomes NaN-NaN-NaN,. Why?

problem description

vue v-for takes a timestamp, then adds a filter, and becomes a NaN-NaN-NaN, without a filter, which can be displayed normally. What is the reason for this

the environmental background of the problems and what methods you have tried

v-for ws.craeateTime 13formatDate


related codes

/ / Please paste the code text below (do not replace the code with pictures)

<div  v-for=" ws in wmessage"  class="wmessageBoxTop">
    <div class="wmessageBoxTopleft">

</div> <ul class="wmessageBoxTopright"> <li>

</li> <li class="wmessageBoxTopTime"> <div>

{{ws.createTime | formatDate}}

>>>

</div> </li> </ul> </div>

selector

filters: {
       formatDate: function (value) {
        var date = new Date(value);//10*1000131000
    var Y = date.getFullYear() + "-";
    var M = (date.getMonth()+1 < 10 ? "0"+(date.getMonth()+1) : date.getMonth()+1) + "-";
    var D = date.getDate() + " ";
    var h = date.getHours() + ":";
    var m = date.getMinutes() + ":";
    var s = date.getSeconds();
    return Y+M+D+h+m+s;
      }
    },

what result do you expect? What is the error message actually seen?




Sep.01,2021

whether it is because the string returned to you by the background is a string, you have to convert the string to a number

first.
formatDate: function (value) {
    var val = JSON.parse(value)
    var date = new Date(val);//10*1000131000
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
    var D = date.getDate() + ' ';
    var h = date.getHours() + ':';
    var m = date.getMinutes() + ':';
    var s = date.getSeconds();
    return Y+M+D+h+m+s;
}

js timestamp conversion requires 10-bit timestamp conversion, JAVA requires 13-bit timestamp, PHP requires 10
you print, your passed value and converted value


var date = new Date(parseInt(value));

if I put it in computed to get the timestamp, why is it still NaN

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45c61-44b6d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45c61-44b6d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?