Vue js timer

in template

<li v-for="item in items">
                    <p class="time"><span>{{ item.timer }}</span>

<div class="main self"> <img class="avatar" src="@/assets/img/2.jpg" alt="" /> <div class="text"> {{ item.label }} </div> </div> </li>

in data

            timer: "",
            items: [],
            newItem: "",

in methods

seed() {
            if(this.$refs.textarea.value === "") {
                this.$Message.error("");
            } else {
                var date = new Date();
                var hour = date.getHours(); //
                var minute = date.getMinutes(); //
                var second = date.getSeconds(); //
                if(hour < 10 ) {
                    hour = "0" + hour
                }
                if(minute < 10){
                    minute = "0" + minute
                }
                if(second < 10){
                    second = "0" + second
                }
                
                this.timer = hour + ":" + minute + ":" + second;
                this.items.push({
                    label: this.newItem,
                    isFinished: false,
                    timer: this.timer
                })
                this.newItem = "";
            }
        }

clipboard.png

the problem now is: the time will be displayed every time you click to send, but I want to show the time every three minutes. How to solve it

Jul.01,2021

you can record the last sending time every time it is sent successfully, and the next time you send it, you can judge whether


visual observation is a dialogue function, confirm one point, and confirm what method is used to complete the similar function.
1. Polling: temporarily save the sending time when sending, and compare the cache time with the current time in each poll, so as to meet the conditions for subsequent operations.
2. Long polling / websocket: is handed over to the backend to listen for time and returns an identity.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30674-2bd0b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30674-2bd0b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?