Vue event execution delay

 

Welcome to discuss

Geooo personal blog: https://geooo.gitee.io/geoooblog/

Foreword

Scenario 1

We need to delay the processing of business functions

Scenario 2

Sometimes users need to repeatedly click event, a short time need to send multiple asynchronous requests

Scenario 3

Controls need to be delayed when the page loads displayed to the customer to observe

supplement

I just watched the Baidu search, Baidu search box, you enter a thing, he would think of search terms listed below. For example, you quickly enter 'abc' three letters in the search box when he was not actually sent a query each letter. But you are a little slow input a, b, c this time to send a three queries.

Then we need to use the setTimeout method Vue methods needed to delay treatment

created () {
    this.loading = this.$loading({
      type: 'text',
      text: '加载中,请稍等...' }) //此处写调用接口 var t = setTimeout(function () { this.loading.close() console.log('加载框已关闭...') }, 1000); }

Guess you like

Origin www.cnblogs.com/Geooo/p/11279492.html