vButton.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <van-button
  3. v-bind="{...$props}"
  4. :disabled="dDisabled"
  5. :loading="dLoading"
  6. :class="type"
  7. @click="$emit('click',$event);toNext()"
  8. >
  9. <slot></slot>
  10. </van-button>
  11. </template>
  12. <script>
  13. export default {
  14. name: "v-button",
  15. props: {
  16. type: {
  17. default: "",
  18. require: false,
  19. type: String,
  20. },
  21. size: {
  22. default: "normal",
  23. require: false,
  24. type: String,
  25. },
  26. text: {
  27. default: undefined,
  28. require: false,
  29. type: String,
  30. },
  31. color: {
  32. default: undefined,
  33. require: false,
  34. type: String,
  35. },
  36. icon: {
  37. default: '',
  38. require: false,
  39. type: String,
  40. },
  41. iconPrefix: {
  42. default: '',
  43. require: false,
  44. type: String,
  45. },
  46. block: {
  47. default: false,
  48. require: false,
  49. type: Boolean,
  50. },
  51. plain: {
  52. default: false,
  53. require: false,
  54. type: Boolean,
  55. },
  56. square: {
  57. default: false,
  58. require: false,
  59. type: Boolean,
  60. },
  61. round: {
  62. default: false,
  63. require: false,
  64. type: Boolean,
  65. },
  66. disabled: {
  67. default: false,
  68. require: false,
  69. type: Boolean,
  70. },
  71. hairline: {
  72. default: false,
  73. require: false,
  74. type: Boolean,
  75. },
  76. loading: {
  77. default: false,
  78. require: false,
  79. type: Boolean,
  80. },
  81. loadingText: {
  82. default: "loading...",
  83. require: false,
  84. type: String,
  85. },
  86. loadingType: {
  87. default: "circular",
  88. require: false,
  89. type: String,
  90. },
  91. loadingSize: {
  92. default: "14px",
  93. require: false,
  94. type: String,
  95. },
  96. url: {
  97. default: "",
  98. require: false,
  99. type: String,
  100. },
  101. to: {
  102. default: "",
  103. require: false,
  104. type: String|Object,
  105. },
  106. replace: {
  107. default: false,
  108. require: false,
  109. type: Boolean,
  110. },
  111. },
  112. data() {
  113. return {
  114. dLoading: this.loading,
  115. dDisabled: this.disabled,
  116. };
  117. },
  118. methods: {
  119. toNext(){
  120. if(this.to){
  121. if(this.replace){
  122. this._router.replace(this.to)
  123. }else{
  124. this._router.push(this.to)
  125. }
  126. }
  127. }
  128. },
  129. watch: {
  130. loading(n) {
  131. this.dLoading = n;
  132. },
  133. disabled(n) {
  134. this.dDisabled = n;
  135. },
  136. },
  137. };
  138. </script>
  139. <style lang="scss" scoped>
  140. .theme {
  141. ::v-deep uni-button {
  142. background: $theme-1;
  143. color: #fff;
  144. border: 1px solid $theme-1;
  145. }
  146. }
  147. .blue {
  148. ::v-deep uni-button {
  149. background: $gradient-blue;
  150. color: #fff;
  151. border:none;
  152. border-radius:inherit;
  153. }
  154. }
  155. .yellow {
  156. ::v-deep uni-button {
  157. background: #F7c264;
  158. color: #2c2c2c;
  159. border:none;
  160. border-radius:inherit;
  161. }
  162. }
  163. .green {
  164. ::v-deep uni-button {
  165. background: $gradient-green;
  166. color: #fff;
  167. border:none;
  168. border-radius:inherit;
  169. }
  170. }
  171. .green-plain {
  172. ::v-deep uni-button {
  173. background: transparent;
  174. color: $green;
  175. border: 1px solid $green;
  176. border-radius:inherit;
  177. padding-left: 2px;
  178. padding-right: 2px;
  179. }
  180. }
  181. .red {
  182. ::v-deep uni-button {
  183. background: $gradient-red;
  184. color: #fff;
  185. border:none;
  186. border-radius:inherit;
  187. }
  188. }
  189. </style>