| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <view
- class="k-button-group"
- :style="{
- paddingBottom: safeArea && `${bottomSafeArea || 10}px`,
- boxShadow: boxShadow ? '0 2px 12px 0 rgba(0, 0, 0, 0.1)' : '',
- }"
- >
- <button
- v-for="(button, index) in list"
- class="k-button"
- :style="{
- color: button.color,
- backgroundColor: button.background,
- border: `2rpx solid ${button.borderColor || 'transparent'}`,
- }"
- @click="onClick(index)"
- :key="index"
- >
- {{ button.label }}
- </button>
- </view>
- </template>
-
- <script>
- export default {
- options: {
- virtualHost: true,
- },
- props: {
- safeArea: {
- type: Boolean,
- default: true,
- },
- boxShadow: {
- type: Boolean,
- default: true,
- },
- options: {
- type: [Array, Object],
- default: () => [],
- },
- label: {
- type: String,
- default: "",
- }
- },
- computed: {
- list() {
- if (JSON.stringify(this.options) !== "{}" && this.options.length > 0) {
- return Array.isArray(this.options) ? this.options : [this.options];
- } else {
- return [
- {
- label: this.label,
- color: "white",
- background: "#005CEEFF",
- },
- ];
- }
- },
- },
- data() {
- return {
- bottomSafeArea: uni.getSystemInfoSync().safeAreaInsets.bottom,
- };
- },
- methods: {
- onClick(index) {
- this.$emit("onClick", index);
- },
- },
- };
- </script>
- <style lang="scss">
- .k-button-group {
- box-sizing: border-box;
- display: flex;
- flex-direction: row;
- background-color: white;
- width: 100%;
- padding: 20rpx 30rpx;
- column-gap: 24rpx;
- .k-button {
- width: 100%;
- font-size: 32rpx;
- }
- }
- </style>
|