<body> <div id="root"> <h2>Display formatted time</h2> <!-- Computed property implementation --> <h2>It is {{fmtTime}}</h2> <!-- Methods implementation --> <h2>Now is {{getFmtTime()}}</h2> <!-- Filter time implementation--> <h2>It is {{time | timeFormater}}</h2> </div> <div id="root2"> <h2>Now: {{msg |mySlice }}</h2> </div> <script> Vue.config.productionTip = false; //Global filter Vue.filter('mySlice', function(value) { return value.slice(0, 4) }) new Vue({ el: "#root", data: { time: 1637047951556 //timestamp}, computed: { fmtTime() { return dayjs(this.time).format('YYYY year MM month DD HH:mm:ss') } }, methods: { getFmtTime() { return dayjs(this.time).format('YYYY year MM month DD HH:mm:ss') } }, filters: timeFormater(value) { return dayjs(value).format('YYYY year MM month DD HH: mm: ss ') } }, }) new Vue({ el: "#root2", data: { msg: 'hello world' } }) </script> </body> SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Solution to prevent caching in pages
>>: How to Completely Clean Your Docker Data
Written in advance: In the following steps, you n...
Programs in Docker containers often need to acces...
Table of contents 1. Proxy in LAN 2. Intranet pen...
(I) Installation of mysql5.7: ❀ Details: The inst...
They are all web page templates from the foreign ...
I recently started learning the NestJs framework....
RPM package management A packaging and installati...
This article is mainly to take you to quickly und...
Scenario simulation: The operation and maintenanc...
First: via text/HTML var txt1="<h1>Tex...
Table of contents environment Install CentOS Conf...
1. Make a repo file Refer to the official install...
Basic three-column layout .container{ display: fl...
introduction: Nowadays, many dynamic verification...
Table of contents Preface 1. Get the current time...