feat: cell组件border属性以props为最高优先级 (#656)

* feat:  cell组件border属性以props为最高优先级

* refactor: ♻️  替换`??`运算符为更兼容的方式
This commit is contained in:
Jasper 2024-10-16 17:00:09 +08:00 committed by GitHub
parent b2b2db0a8a
commit 31353ceafa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 4 deletions

View File

@ -69,7 +69,8 @@
```html
<wd-cell-group title="交易管理" border>
<wd-cell title="标题文字" value="内容"></wd-cell>
<wd-cell title="标题文字" value="内容" />
<wd-cell :border="false" title="标题文字" label="这一个cell不想要边框" value="内容" />
<wd-cell title="标题文字" label="描述信息" value="内容"></wd-cell>
</wd-cell-group>
```

View File

@ -37,6 +37,7 @@
<demo-block title="展示边框线" transparent>
<wd-cell-group title="交易管理" border>
<wd-cell title="标题文字" value="内容" />
<wd-cell :border="false" title="标题文字" label="这一个cell不想要边框" value="内容" />
<wd-cell title="标题文字" label="描述信息" value="内容"></wd-cell>
</wd-cell-group>
</demo-block>

View File

@ -358,6 +358,10 @@ export function isNotUndefined<T>(value: T): value is NotUndefined<T> {
return !isUndefined(value)
}
export function isNone(value: any): value is null | undefined {
return value === null || value === void 0
}
/**
*
* @param value

View File

@ -44,7 +44,7 @@ export const cellProps = {
/**
* 线
*/
border: Boolean,
border: makeBooleanProp(void 0),
/**
*
*/

View File

@ -63,7 +63,7 @@ import { useCell } from '../composables/useCell'
import { useParent } from '../composables/useParent'
import { FORM_KEY } from '../wd-form/types'
import { cellProps } from './types'
import { isDef } from '../common/util'
import { isNone } from '../common/util'
const props = defineProps(cellProps)
const emit = defineEmits(['click'])
@ -71,7 +71,7 @@ const emit = defineEmits(['click'])
const cell = useCell()
const isBorder = computed(() => {
return isDef(cell.border.value) ? cell.border.value : props.border
return Boolean(!isNone(props.border) ? props.border : cell.border.value)
})
const { parent: form } = useParent(FORM_KEY)