myButton.js 757 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // components/myButton/myButton.js
  2. Component({
  3. options: {
  4. styleIsolation: 'apply-shared'
  5. },
  6. behaviors: ['wx://form-field-button'],
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. type: String,
  12. size: String
  13. },
  14. lifetimes: {
  15. attached: function () {
  16. if (this.data.type !== 'default' && this.data.type !== 'primary') {
  17. this.setData({
  18. type: 'default'
  19. })
  20. }
  21. if (this.data.size !== 'default' && this.data.type !== 'large') {
  22. this.setData({
  23. size: 'default'
  24. })
  25. }
  26. }
  27. },
  28. /**
  29. * 组件的初始数据
  30. */
  31. data: {
  32. },
  33. /**
  34. * 组件的方法列表
  35. */
  36. methods: {
  37. handleTap: function () {
  38. this.triggerEvent('tap');
  39. }
  40. }
  41. })