index.js 2.0 KB

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