云链智安app
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

KBottomButton.vue 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view
  3. class="k-button-group"
  4. :style="{
  5. paddingBottom: safeArea && `${bottomSafeArea || 10}px`,
  6. boxShadow: boxShadow ? '0 2px 12px 0 rgba(0, 0, 0, 0.1)' : '',
  7. }"
  8. >
  9. <button
  10. v-for="(button, index) in list"
  11. class="k-button"
  12. :style="{
  13. color: button.color,
  14. backgroundColor: button.background,
  15. border: `2rpx solid ${button.borderColor || 'transparent'}`,
  16. }"
  17. @click="onClick(index)"
  18. :key="index"
  19. >
  20. {{ button.label }}
  21. </button>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. options: {
  27. virtualHost: true,
  28. },
  29. props: {
  30. safeArea: {
  31. type: Boolean,
  32. default: true,
  33. },
  34. boxShadow: {
  35. type: Boolean,
  36. default: true,
  37. },
  38. options: {
  39. type: [Array, Object],
  40. default: () => [],
  41. },
  42. label: {
  43. type: String,
  44. default: "",
  45. }
  46. },
  47. computed: {
  48. list() {
  49. if (JSON.stringify(this.options) !== "{}" && this.options.length > 0) {
  50. return Array.isArray(this.options) ? this.options : [this.options];
  51. } else {
  52. return [
  53. {
  54. label: this.label,
  55. color: "white",
  56. background: "#005CEEFF",
  57. },
  58. ];
  59. }
  60. },
  61. },
  62. data() {
  63. return {
  64. bottomSafeArea: uni.getSystemInfoSync().safeAreaInsets.bottom,
  65. };
  66. },
  67. methods: {
  68. onClick(index) {
  69. this.$emit("onClick", index);
  70. },
  71. },
  72. };
  73. </script>
  74. <style lang="scss">
  75. .k-button-group {
  76. box-sizing: border-box;
  77. display: flex;
  78. flex-direction: row;
  79. background-color: white;
  80. width: 100%;
  81. padding: 20rpx 30rpx;
  82. column-gap: 24rpx;
  83. .k-button {
  84. width: 100%;
  85. font-size: 32rpx;
  86. }
  87. }
  88. </style>