index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var component_1 = require('../common/component');
  4. var button_1 = require('../mixins/button');
  5. var open_type_1 = require('../mixins/open-type');
  6. var version_1 = require('../common/version');
  7. var mixins = [button_1.button, open_type_1.openType];
  8. if (version_1.canIUseFormFieldButton()) {
  9. mixins.push('wx://form-field-button');
  10. }
  11. component_1.VantComponent({
  12. mixins: mixins,
  13. classes: ['hover-class', 'loading-class'],
  14. data: {
  15. baseStyle: '',
  16. },
  17. props: {
  18. formType: String,
  19. icon: String,
  20. classPrefix: {
  21. type: String,
  22. value: 'van-icon',
  23. },
  24. plain: Boolean,
  25. block: Boolean,
  26. round: Boolean,
  27. square: Boolean,
  28. loading: Boolean,
  29. hairline: Boolean,
  30. disabled: Boolean,
  31. loadingText: String,
  32. customStyle: String,
  33. loadingType: {
  34. type: String,
  35. value: 'circular',
  36. },
  37. type: {
  38. type: String,
  39. value: 'default',
  40. },
  41. dataset: null,
  42. size: {
  43. type: String,
  44. value: 'normal',
  45. },
  46. loadingSize: {
  47. type: String,
  48. value: '20px',
  49. },
  50. color: {
  51. type: String,
  52. observer: function (color) {
  53. var style = '';
  54. if (color) {
  55. style += 'color: ' + (this.data.plain ? color : 'white') + ';';
  56. if (!this.data.plain) {
  57. // Use background instead of backgroundColor to make linear-gradient work
  58. style += 'background: ' + color + ';';
  59. }
  60. // hide border when color is linear-gradient
  61. if (color.indexOf('gradient') !== -1) {
  62. style += 'border: 0;';
  63. } else {
  64. style += 'border-color: ' + color + ';';
  65. }
  66. }
  67. if (style !== this.data.baseStyle) {
  68. this.setData({ baseStyle: style });
  69. }
  70. },
  71. },
  72. },
  73. methods: {
  74. onClick: function () {
  75. if (!this.data.loading) {
  76. this.$emit('click');
  77. }
  78. },
  79. noop: function () {},
  80. },
  81. });