In vue, go to the database and request the data back. If the database data changes, how can the page change automatically?

problem description

for example, if the background management system modifies the data, how can the front-end page retrieve the data in time?

the environmental background of the problems and what methods you have tried

set,watch,computed that has used vue also failed to solve

related codes

/ / Please paste the code text below (do not replace the code with pictures)

< template >

<div id="app">
    

{{id}}

<router-view/> </div>

< / template >

< script >

export default {
    name: "App",
    data() {
        return {
            id: "images_show"
        }
    },
    methods: {
        getRouterLink () {
            this.$axios.get("http://192.168.0.182:8084/Temp/temp1").then(
                res => {
                    console.log(res.data,);
                    this.id = res.data;
                    if (this.id === "images_show") {
                        this.$router.push("/")
                    } else if (this.id === "change_video") {
                        this.$router.push("/media")
                    } else if (this.id === "change_luck") {
                        this.$router.push("/random")
                    } else if (this.id === "change_photoes") {
                        this.$router.push("/voice")
                    }else if (this.id === "change_voice") {
                        this.$router.push("/admin")
                    }
                }
            ).catch(
                err => {
                    console.log(err);
                }
            );

        }
    },
    created() {
        this.getRouterLink()
    }
}

what result do you expect? What is the error message actually seen?

I hope God can answer, or give another idea; it is best to be able to re-request the interface if the data in the database has changed without refreshing the page.

Apr.07,2022

worker polling. Of course, the best solution is to websocket


webSocket . When the database changes, it is pushed to the front end, and then the front end adjusts the interface again to get the latest data


the simplest method setTimeOut or setInterval

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-1b3db82-4f01d.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-1b3db82-4f01d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?