hldy_app/uni_modules/vk-uview-ui/components/u-gap/u-gap.vue

55 lines
1.5 KiB
Vue
Raw Normal View History

2025-04-08 17:33:14 +08:00
<template>
<view class="u-gap" :style="[gapStyle]"></view>
</template>
<script>
/**
* gap 间隔槽
* @description 该组件一般用于内容块之间的用一个灰色块隔开的场景方便用户风格统一减少工作量
* @tutorial https://www.uviewui.com/components/gap.html
* @property {String} bg-color 背景颜色默认#f3f4f6
* @property {String Number} height 分割槽高度单位rpx默认30
* @property {String Number} margin-top 与前一个组件的距离单位rpx默认0
* @property {String Number} margin-bottom 与后一个组件的距离单位rpx0
* @example <u-gap height="80" bg-color="#bbb"></u-gap>
*/
export default {
name: "u-gap",
props: {
bgColor: {
type: String,
default: 'transparent ' // 背景透明
},
// 高度
height: {
type: [String, Number],
default: 30
},
// 与上一个组件的距离
marginTop: {
type: [String, Number],
default: 0
},
// 与下一个组件的距离
marginBottom: {
type: [String, Number],
default: 0
},
},
computed: {
gapStyle() {
return {
backgroundColor: this.bgColor,
height: isNaN(this.height) ? this.height : this.height + 'rpx',
marginTop: isNaN(this.marginTop) ? this.marginTop : this.marginTop + 'rpx',
marginBottom: isNaN(this.marginBottom) ? this.marginBottom : this.marginBottom + 'rpx'
};
}
}
};
</script>
<style lang="scss" scoped>
@import "../../libs/css/style.components.scss";
</style>