Skip to content

Instantly share code, notes, and snippets.

@luckyadam
Last active July 9, 2018 14:15
Show Gist options
  • Save luckyadam/507785a4b1039b6e329e3cbb1d7294ae to your computer and use it in GitHub Desktop.
Save luckyadam/507785a4b1039b6e329e3cbb1d7294ae to your computer and use it in GitHub Desktop.
Component({
  properties: {
    myProperty: { // 属性名
      type: String
    },
    myProperty2: String // 简化的定义方式
  },
  
  data: {}, // 私有数据,可用于模版渲染
  
  // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  ready: function () {},
  
  attached: function(){},
  
  moved: function(){},
  
  detached: function(){},

  methods: {
    onMyButtonTap: function(){
      this.setData({
        // 更新属性和数据的方法与更新页面数据的方法类似
      })
    }
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment