-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d995337
commit 22ab4fe
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<view class="pi-gap" :style="[gapStyle]"> | ||
<slot /> | ||
</view> | ||
</template> | ||
|
||
<script> | ||
/** | ||
* 间隔槽 | ||
*/ | ||
import { getConfig } from '../../config' | ||
const { gap } = getConfig() | ||
const TAG = 'PiGap' | ||
export default { | ||
name: TAG, | ||
props: { | ||
// 自定义样式,对象形式(默认值:{}) | ||
customStyle: { | ||
type: Object, | ||
default() { | ||
return gap.customStyle | ||
} | ||
}, | ||
// 自定义样式类,字符串形式('') | ||
customClass: { | ||
type: String, | ||
default() { | ||
return gap.customClass | ||
} | ||
}, | ||
// 背景颜色(默认透明) | ||
background: { | ||
required: false, | ||
type: String, | ||
default: gap.background | ||
}, | ||
// 高度 | ||
height: { | ||
type: [String, Number], | ||
default: gap.height | ||
}, | ||
// 与上一个组件的距离 | ||
marginTop: { | ||
type: [String, Number], | ||
default: gap.marginTop | ||
}, | ||
// 与下一个组件的距离 | ||
marginBottom: { | ||
type: [String, Number], | ||
default: gap.marginBottom | ||
} | ||
}, | ||
computed: { | ||
gapStyle() { | ||
return { | ||
backgroundColor: this.background, | ||
height: this.$pi.common.addUnit(this.height), | ||
marginTop: this.$pi.common.addUnit(this.marginTop), | ||
marginBottom: this.$pi.common.addUnit(this.marginBottom) | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
customClass: '', // 自定义样式类,字符串形式('') | ||
customStyle: {}, // 自定义样式,对象形式(默认值:{}) | ||
background: '#F4F4F4', // 背景颜色 | ||
height: 24, // 高度 | ||
marginTop: 0, // 顶部间距 | ||
marginBottom: 0 // 底部间距 | ||
} |