this. $ nextTick (). html page after the data has been refreshed, then perform the method in the callback function

was vm = new Vue ({
the '# app'
data: {msg: 'Hsiao Ming'},
methods: {
change(){
this.msg = 'small green'
console.log (document.getElementById ( 'p1') innerText.); // Xiaoming, is asynchronous because this.msg
 
}
},
 
});
 
Solutions
 
was vm = new Vue ({
the '# app'
data: {msg: 'Hsiao Ming'},
methods: {
change(){
this.msg = 'small green'
this.$nextTick(()=>{
console.log(document.getElementById('p1').innerText); //小明
})
 
}
},
 
});
 
 

Guess you like

Origin www.cnblogs.com/xiannv/p/10993439.html