Date component el-date-picke data format issues

want to change the date format to the format of the year, month and day. The following figure shows the obtained date data

clipboard.png

date-fns plug-in is installed. I wonder if there is a problem with import

import dateFns from "date-fns"

format the date data

ApplyDate: this.listQuery.ApplyDate ? dateFns.format(this.listQuery.ApplyDate, "YYYY-MM-DD") : "",

output date data in a table

<el-table-column prop="name" label="">
    <template slot-scope="scope">
      <span>{{scope.row.ApplyDate | timeForamter}}</span>
    </template>
</el-table-column>

the first time I used this plug-in, I couldn"t open the official document and typed it according to other people"s code. I don"t know which step went wrong

Apr.19,2021

according to the way you write
{{scope.row.ApplyDate | timeForamter}}
"timeForamter" is a filter, you have to hang it on Vue in main.js first.


actually you can use moment.js for date formatting and it's convenient


<el-table-column prop="name" label="">
    <template slot-scope="scope">
      <span>{{scope.row.ApplyDate}}</span>
    </template>
</el-table-column>

remove the filter. You can break the point and cosole your ApplyDate to see what the time format is returned to you by the background

.
Menu