Why can't new and old variables be compared in this way in vue?

execute a getAll method in an interval timer. This getAll method will read an interface using axios loop. Once the interface data changes, the new data will be written into vue.count. What I want to achieve now is that once the vue.count changes, the alert pop-up box and the audio tag play the sound, but I find that this has no effect. What is the reason? Why are old and new always the same?


watch you deserve


because you vue.old=vue.count these two are always equal, and you compare them later, you can use watch to implement this scenario, or
do not assign a value

.
if(vue.count===vue.old){
    
}else{
    alert('new message')
}

you can refer to this way of writing

    new Vue({
        el: "-sharpapp",
        data() {
            return {
                count: ''
            }
        },
        methods: {
            getAll() {
                return new Promise((resolve, reject) => {
                    axios.get('../json/menu.json').then(res => {
                        resolve(res.data)
                    })
                })
            }
        },
        watch: {
            count: function () {
                alert('')
            }
        },
        mounted() {
            let that = this;
            setInterval(async () => {
                that.count = await that.getAll()
            }, 5000);
        }
    })

use watch to listen on count

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