<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
Table of contents Modify the repository source st...
Table of contents vue router 1. Understand the co...
This method uses the drop-shadow filter in CSS3 t...
MySQL multi-condition query with AND keyword. In ...
There are two types of web page box models: 1: Sta...
Table of contents 1. Plugins 2. Interlude 3. Impl...
There are three types of virtual hosts supported ...
What is a Port? The ports we usually refer to are...
The specific code is as follows: /*Scroll bar wid...
This article shares the specific code for JavaScr...
Without relying on JavaScript, pure CSS is used t...
Preface: Use debugbar to view document code in iet...
Configuring network connectivity for Linux system...
What is Virtual Memory? First, I will directly qu...
This article shares the specific code for WeChat ...