How to delay a button display to 2s in Vuejs

Viewed 915

I have a button component which I am using in several places. But I want to show that button after 2s on a specific page. How can I achieve this in Vuejs/CSS?

<OHButton
        v-show="this.campIndex < 2 && modalShow"
        :title="'next'"
        :onClick="goToSlides"
      >
</OHButton>

1 Answers

Define a data property called delayShow and in created hook use setTimeout function to set it to true:

data(){
  return{
   delayShow:false,
 ...   

 }
},
created(){
 setTimeout(()=>{
  this.delayShow=true;
},2000)
}

in template :

<OHButton
        v-show="delayShow && modalShow"
        :title="'next'"
        @click="goToSlides"
      >
</OHButton>
Related