A little doubt about learning Vue.nextTick

var vm = new Vue({
    el: "-sharpexample",
    data: {
        message: "123"
    }
})

vm.message = "new message"

console.log(vm.$el.textContent)

Vue.nextTick(function () {

    console.log(vm.$el.textContent)

})

read some Vue.nextTick instructions on the Internet, saying that the operation will be carried out during the next task cycle (that is, after the DOM update is completed).

clipboard.png


vm.$el vmChrometextContent

:

clipboard.png

:

clipboard.png

Why is this?


when you use the chrome console to view, when you click on the properties, Chrome will query the properties of that value. If you don't believe it, you can turn JSON.stringify (vm) into a JSON string and see


console prints references, vm is always the same object, so you expand to see the same content. You can enter a breakpoint console.log (vm); debugger; in the first log statement to see the value printed by vm at this time.


because vm is an Object reference type data, vm only points to an address reference, and the actual data is stored in the heap.

if you click to view faster than the machine runs, then you can see the results you want to see.
in fact, when you click to view, the value has already changed according to the reference point

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