index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. component_1.VantComponent({
  7. mixins: [button_1.button, open_type_1.openType],
  8. classes: ['hover-class', 'loading-class'],
  9. data: {
  10. baseStyle: ''
  11. },
  12. props: {
  13. icon: String,
  14. plain: Boolean,
  15. block: Boolean,
  16. round: Boolean,
  17. square: Boolean,
  18. loading: Boolean,
  19. hairline: Boolean,
  20. disabled: Boolean,
  21. loadingText: String,
  22. customStyle: String,
  23. loadingType: {
  24. type: String,
  25. value: 'circular'
  26. },
  27. type: {
  28. type: String,
  29. value: 'default'
  30. },
  31. size: {
  32. type: String,
  33. value: 'normal'
  34. },
  35. loadingSize: {
  36. type: String,
  37. value: '20px'
  38. },
  39. color: {
  40. type: String,
  41. observer: function (color) {
  42. var style = '';
  43. if (color) {
  44. style += "color: " + (this.data.plain ? color : 'white') + ";";
  45. if (!this.data.plain) {
  46. // Use background instead of backgroundColor to make linear-gradient work
  47. style += "background: " + color + ";";
  48. }
  49. // hide border when color is linear-gradient
  50. if (color.indexOf('gradient') !== -1) {
  51. style += 'border: 0;';
  52. }
  53. else {
  54. style += "border-color: " + color + ";";
  55. }
  56. }
  57. if (style !== this.data.baseStyle) {
  58. this.setData({ baseStyle: style });
  59. }
  60. }
  61. }
  62. },
  63. methods: {
  64. onClick: function () {
  65. if (!this.data.disabled && !this.data.loading) {
  66. this.$emit('click');
  67. }
  68. }
  69. }
  70. });