lv-button.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <button
  3. class="lv-button"
  4. :class="['lv-type-' + type, round ? 'round' : '', hand ? 'hand' : '', size]"
  5. :style="styleObject"
  6. @click="handleClick">
  7. <slot></slot>
  8. </button>
  9. </template>
  10. <script>
  11. export default {
  12. name: 'lv-button',
  13. props: {
  14. type: {
  15. type: String,
  16. default: 'default'
  17. },
  18. round: {
  19. type: Boolean,
  20. default: false
  21. },
  22. hand: {
  23. type: Boolean,
  24. default: false
  25. },
  26. size: {
  27. type: String,
  28. default: 'medium'
  29. },
  30. bgColor: String,
  31. fontColor: String,
  32. },
  33. data () {
  34. return {
  35. styleObject: {}
  36. }
  37. },
  38. mounted() {
  39. if (this.bgColor) {
  40. this.$set(this.styleObject, 'background-color', this.bgColor);
  41. this.$set(this.styleObject, 'border-color', this.bgColor);
  42. }
  43. if (this.fontColor) {
  44. this.$set(this.styleObject, 'color', this.fontColor);
  45. }
  46. },
  47. methods: {
  48. handleClick(env) {
  49. this.$emit('click', env)
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="less" scope>
  55. @import url('../public/less/color');
  56. .lv {
  57. &-button {
  58. border: 0;
  59. margin: 0;
  60. color: @black;
  61. font-size: var(--main_font_size, 14px);
  62. user-select: none;
  63. padding: 6px 20px;
  64. border: solid 1px @border;
  65. background-color: @white;
  66. margin: 0 2px;
  67. &.round {
  68. border-radius: 20px;
  69. }
  70. &.hand {
  71. cursor: pointer;
  72. }
  73. &.small {
  74. padding: 3px 10px;
  75. }
  76. &.big {
  77. padding: 10px 20px;
  78. }
  79. &[disabled] {
  80. opacity: .5;
  81. }
  82. }
  83. &-type-primary {
  84. color: @white;
  85. border: solid 1px @primary;
  86. background-color: @primary;
  87. }
  88. &-type-success {
  89. color: @white;
  90. border: solid 1px @success;
  91. background-color: @success;
  92. }
  93. &-type-info {
  94. color: @white;
  95. border: solid 1px @info;
  96. background-color: @info;
  97. }
  98. &-type-warning {
  99. color: @white;
  100. border: solid 1px @warning;
  101. background-color: @warning;
  102. }
  103. &-type-danger {
  104. color: @white;
  105. border: solid 1px @danger;
  106. background-color: @danger;
  107. }
  108. }
  109. </style>