[+] Format date with moment
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
|
"moment": "^2.29.1",
|
||||||
"vue": "^3.0.0",
|
"vue": "^3.0.0",
|
||||||
"vue-class-component": "^8.0.0-0",
|
"vue-class-component": "^8.0.0-0",
|
||||||
"vue-i18n": "^9.2.0-beta.23",
|
"vue-i18n": "^9.2.0-beta.23",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {Options, Vue} from 'vue-class-component';
|
import {Options, Vue} from 'vue-class-component';
|
||||||
import {backendUrl} from "@/constants";
|
import {backendUrl} from "@/constants";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
export interface Post {
|
export interface Post {
|
||||||
id: string
|
id: string
|
||||||
@@ -53,6 +54,8 @@ export default class Blog extends Vue
|
|||||||
{
|
{
|
||||||
fetch(`${backendUrl}/posts.json`).then(it => it.json()).then(it => {
|
fetch(`${backendUrl}/posts.json`).then(it => it.json()).then(it => {
|
||||||
this.posts = it
|
this.posts = it
|
||||||
|
this.posts.forEach(it => it.date = moment(it.date).format('YYYY-MM-DD h:mm'))
|
||||||
|
this.posts.reverse()
|
||||||
console.log(it)
|
console.log(it)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user