observers: {
    'show': function (val) {
      const that = this;
      that.setData({
        showTitlt: val
      }, () => {
        if(val){
          setTimeout(() => {
            that.triggerEvent('myevent', false)
          }, 2000)
        }
      })
    }
  }

全JS

子组件监听父组件传递信息 observers_属性列表子组件监听父组件传递信息 observers_数据_02
// components/warn/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      default: false,
      value: '登录失败'
    },
    show: {
      type: Boolean,
      default: false
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    showTitlt:false 
  },

  /**
   * 组件的方法列表
   */
  methods: {

  },
  observers: {
    'show': function (val) {
      const that = this;
      that.setData({
        showTitlt: val
      }, () => {
        if(val){
          setTimeout(() => {
            that.triggerEvent('myevent', false)
          }, 2000)
        }
      })
    }
  }
})
View Code