test5.js 560 B

1234567891011121314151617181920212223242526272829303132
  1. // components/test5/test5.js
  2. const myBehavior = require('../../behaviors/my-behavior')
  3. Component({
  4. behaviors: [myBehavior],
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. count: Number
  10. },
  11. /**
  12. * 组件的初始数据
  13. */
  14. data: {
  15. username: 'ls'
  16. },
  17. /**
  18. * 组件的方法列表
  19. */
  20. methods: {
  21. addCount() {
  22. this.setData({
  23. count: this.properties.count + 1
  24. })
  25. // 触发自定义事件,将数值同步给父组件
  26. this.triggerEvent('sync', { value: this.properties.count })
  27. }
  28. }
  29. })