zoukankan      html  css  js  c++  java
  • 子组件监听父组件传递信息 observers

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

    全JS

    // 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
  • 相关阅读:
    通知
    KVO详解
    KVC详解
    KVC/KVO总结
    结构体Struct
    检测文件(夹)大小
    NSFileHandle&&NSFileManage
    ***NSFileManager
    获取文件扩展名
    MySql数据库_03
  • 原文地址:https://www.cnblogs.com/lvlisn/p/15238652.html
Copyright © 2011-2022 走看看