Vue wants to implement a problem encountered by using a timer to change the appearance and concealment of DOM.

<el-dialog title="" :visible.sync="matchingOrderShow" width="30%">
  <div v-show="matchingOrderShow_icon">
    <i class="el-icon-loading icon_c_loading"></i>
    

</div> <div v-show="!matchingOrderShow_icon"> </div> </el-dialog>

layout code, click a button to open the pop-up window. The default data value is false Hidden

matchingOrderShow: false,
matchingOrderShow_icon: undefined,

js Code

matchingOrder(){
  this.matchingOrderShow = true
  this.matchingOrderShow_icon = true
  console.log(this.matchingOrderShow_icon)
  setTimeout(function () {
    this.matchingOrderShow_icon = false
    console.log(this.matchingOrderShow_icon)
  },2000)
}
true2dom

clipboard.png


clipboard.png
but the page structure hasn"t changed, so I"d like to ask how to change it

.

if you write setTimeout in this way, it has its own scope of callback. this does not point to vm . The easiest solution is to change it to the arrow function

.
setTimeout(() => {
  this.matchingOrderShow_icon = false;
}, 2000);
Menu