index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. var nativeButtonBehavior = require('./native-button-behaviors');
  3. Component({
  4. externalClasses: ['custom-class', 'theme-class'],
  5. behaviors: [nativeButtonBehavior],
  6. relations: {
  7. '../btn-group/index': {
  8. type: 'parent',
  9. linked: function linked() {
  10. this.setData({ inGroup: true });
  11. },
  12. unlinked: function unlinked() {
  13. this.setData({ inGroup: false });
  14. }
  15. }
  16. },
  17. properties: {
  18. type: {
  19. type: String,
  20. value: ''
  21. },
  22. size: {
  23. type: String,
  24. value: ''
  25. },
  26. plain: {
  27. type: Boolean,
  28. value: false
  29. },
  30. disabled: {
  31. type: Boolean,
  32. value: false
  33. },
  34. loading: {
  35. type: Boolean,
  36. value: false
  37. }
  38. },
  39. data: {
  40. inGroup: false,
  41. isLast: false
  42. },
  43. methods: {
  44. handleTap: function handleTap() {
  45. if (this.data.disabled) {
  46. this.triggerEvent('disabledclick');
  47. return;
  48. }
  49. this.triggerEvent('btnclick');
  50. },
  51. switchLastButtonStatus: function switchLastButtonStatus() {
  52. var isLast = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  53. this.setData({ isLast: isLast });
  54. }
  55. }
  56. });