You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view :class="`wd-gap ${safeAreaBottom ? 'wd-gap--safe' : ''} ${customClass}`" :style="rootStyle"></view>
</template>
<script lang="ts">
export default {
name: 'wd-gap',
options: {
addGlobalClass: true,
virtualHost: true,
styleIsolation: 'shared'
}
}
</script>
<script setup lang="ts">
import { type CSSProperties, computed } from 'vue'
import { addUnit, isDef, objToStyle } from '../common/util'
interface Props {
bgColor?: string
safeAreaBottom?: boolean
customClass?: string
customStyle?: string
height?: string | number
}
const props = withDefaults(defineProps<Props>(), {
// 背景颜色默认transparent
bgColor: 'transparent',
//额外添加底部安全区高度
safeAreaBottom: false,
//分割槽高度单位px
height: 15,
customClass: '',
customStyle: ''
})
const rootStyle = computed(() => {
const rootStyle: CSSProperties = {}
if (isDef(props.bgColor)) {
rootStyle['background'] = props.bgColor
}
if (isDef(props.height)) {
rootStyle['height'] = addUnit(props.height)
}
return `${objToStyle(rootStyle)};${props.customStyle}`
})
</script>
<style lang="scss" scoped>
@import './index.scss';
</style>