Why is nextTick still ineffective?

encountered a problem with using nextTick. The general logic in
is that the init () method takes data from the backend and stores it in this.addressList,. This data change will lead to the change of dom, but according to the principle of response, dom will not change immediately, it is an asynchronous process, so I use the nextTick method to wait for dom to change before getting a default address from it, but this still cannot be obtained. Is it selectedId or an empty string? Excuse me, do I misunderstand the use of nextTick?

mounted(){
            this.init();
            //??
             this.$nextTick(function () {
                 this.addressList.forEach((item)=>{
                            if(item.isDefault){
                                this.selectedId=item.addressId;
                            }
                    })
            })
        },
        methods:{
            init(){
                axios.get("/users/addressList").then((response)=>{
                    var res=response.data;
                    if(res.status==="0"){
                        this.addressList=res.result;
                        //
                        //     this.addressList.forEach((item)=>{
                    //         if(item.isDefault){
                    //             this.selectedId=item.addressId;
                    //         }
                    // })
                    }
                })
            },
Apr.24,2021

I wonder if this can help you understand the purpose of nextTick :

mounted(){
    this.init();
},
methods:{
    init(){
        axios.get('/users/addressList').then((response)=>{
            var res=response.data;
            if(res.status==='0'){
                this.addressList=res.result;
                this.addressList.forEach((item)=>{
                  if(item.isDefault){
                      this.selectedId=item.addressId;
                   }
                });
                this.$nextTick(function() {
                     //data
                })
            }
        })
    }

The

code runs in writing order. You write directly after init and call it directly. Your asynchronous data acquisition request hasn't come back yet.

this dom takes effect means that you are sure that the data has been changed, and during the vue declaration cycle, the nextTick method is provided for the dom change callback.

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