Vue equivalent of setTimeout?

前端 未结 13 2355
栀梦
栀梦 2021-01-30 08:20

I\'m making a shopping cart system with Laravel and Vue. When I add an item to the basket, I display a confirmation message by toggling a Vue variable being watched by a v-if:

13条回答
  •  滥情空心
    2021-01-30 08:33

    You can use Vue.nextTick

    addToBasket: function(){
                    item = this.photo;
                    this.$http.post('/api/buy/addToBasket', item);
                    this.basketAddSuccess = true;
                    Vue.nextTick(() =>{
                        this.basketAddSuccess = false;
                    });
                }
    

提交回复
热议问题