How does vue achieve a function similar to the dynamic display of time by an electronic watch?

the business scenario is shown in the figure, and the current date and time is recorded after clicking. How to achieve it?

< hr >

by the way, it"s dynamic, like an electronic watch.

Mar.01,2021

getData() {
    var t = new Date();//datedate
    var h = t.getHours();
    var m = t.getMinutes();
    var s = t.getSeconds();
    this.time = h + ':' + m + ':' + s;
    let _this = this;
    setTimeout(() => {
      _this.getData();
    }, 1000);
},
The time defined by

is put in the desired location


is very simple
Click var now = new Date () (to convert to the format you need) save this now (where you need it)

Menu