如何在不编写大量 JavaScript 代码的情况下在 Vue.js 中获取完整的当前日期和时间

hul*_*rgg 7 html javascript vue.js

我想在 Vue.js 中打印“上次更新:2019 年 6 月 12 日下午 1:30”。我有当前年份,但我想要完整的日期和时间。这是我到目前为止所拥有的

<div id="app">
Last updated: {{ new Date().getFullYear() }}
</div>
Run Code Online (Sandbox Code Playgroud)

小智 15

你可以使用:new Date().toLocaleString(),它给你"6/13/2019, 9:40:40 AM"