# wx.nextTick(function callback)

Start from base library version 2.2.3. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.7.1

Deferring some operations to the next slice of time. (similar to setTimeout)

# parameter

# function callback

# Introductions

Because the custom component setData and triggerEvent Such interfaces are synchronous operations, when these interfaces are called consecutively, they are executed in a synchronous process, so if the logic is not appropriate, it may lead to errors.

An extreme case: when the parent component s setData That raises the Trigger Event, which causes the parent component to proceed once more SetData, with passing wx:if Statement can cause strange errors by uninstalling subcomponents, so you can use this interface to defer execution to the next time slice for logic that does not need to be completed in a synchronous process.

# sample code

  doSth() {
    this.setData({ number: 1 }) // Execute directly in the current synchronization process

    wx.nextTick(() => {
      this.setData({ number: 3 }) // After the current synchronization process ends, the next time slice executes

    this.setData({ number: 2 }) // Execute directly in the current synchronization process