Skip to content

Commit

Permalink
fix: 🐛 修复 Divider 分割线组件 CustomClass 未生效的问题 (#790)
Browse files Browse the repository at this point in the history
Closes: #789
  • Loading branch information
Moonofweisheng authored Dec 17, 2024
1 parent f3bee13 commit 44df081
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const dividerProps = {
/**
* 自定义颜色
*/
color: makeStringProp(''),
color: String,
/**
* 内容位置,可选值为 `left` `right` `center`
* 默认值:`center`
Expand Down
36 changes: 18 additions & 18 deletions src/uni_modules/wot-design-uni/components/wd-divider/wd-divider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ export default {
</script>

<script lang="ts" setup>
import { computed, useSlots } from 'vue'
import { computed, useSlots, type CSSProperties } from 'vue'
import { dividerProps } from './types'
import { objToStyle } from '../common/util'
const props = defineProps(dividerProps)
const slots = useSlots()
const rootStyle = computed(() => {
return `--wot-divider-color:${props.color};${props.customStyle}`
const { color } = props
const style: CSSProperties = {}
if (color) {
style.color = color
}
return `${objToStyle(style)};${props.customStyle}`
})
const rootClass = computed(() => {
const prefixCls = 'wd-divider'
if (!props.vertical) {
return {
[prefixCls]: true,
[`${prefixCls}--center`]: slots.default,
[`${prefixCls}--left`]: props.contentPosition === 'left',
[`${prefixCls}--right`]: props.contentPosition === 'right',
['is-dashed']: props.dashed,
['is-hairline']: props.hairline
}
} else {
return {
[prefixCls]: true,
[`${prefixCls}--vertical`]: true,
['is-dashed']: props.dashed,
['is-hairline']: props.hairline
}
const classes: Record<string, boolean> = {
[prefixCls]: true,
['is-dashed']: props.dashed,
['is-hairline']: props.hairline,
[`${prefixCls}--vertical`]: props.vertical,
[`${prefixCls}--center`]: !props.vertical && !!slots.default,
[`${prefixCls}--left`]: !props.vertical && props.contentPosition === 'left',
[`${prefixCls}--right`]: !props.vertical && props.contentPosition === 'right',
[props.customClass]: !!props.customClass
}
return classes
})
</script>

Expand Down

0 comments on commit 44df081

Please sign in to comment.