Skip to content

Commit 31353ce

Browse files
authored
feat: ✨ cell组件border属性以props为最高优先级 (#656)
* feat: ✨ cell组件border属性以props为最高优先级 * refactor: ♻️ 替换`??`运算符为更兼容的方式
1 parent b2b2db0 commit 31353ce

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

docs/component/cell.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969

7070
```html
7171
<wd-cell-group title="交易管理" border>
72-
<wd-cell title="标题文字" value="内容"></wd-cell>
72+
<wd-cell title="标题文字" value="内容" />
73+
<wd-cell :border="false" title="标题文字" label="这一个cell不想要边框" value="内容" />
7374
<wd-cell title="标题文字" label="描述信息" value="内容"></wd-cell>
7475
</wd-cell-group>
7576
```

src/pages/cell/Index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<demo-block title="展示边框线" transparent>
3838
<wd-cell-group title="交易管理" border>
3939
<wd-cell title="标题文字" value="内容" />
40+
<wd-cell :border="false" title="标题文字" label="这一个cell不想要边框" value="内容" />
4041
<wd-cell title="标题文字" label="描述信息" value="内容"></wd-cell>
4142
</wd-cell-group>
4243
</demo-block>

src/uni_modules/wot-design-uni/components/common/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ export function isNotUndefined<T>(value: T): value is NotUndefined<T> {
358358
return !isUndefined(value)
359359
}
360360

361+
export function isNone(value: any): value is null | undefined {
362+
return value === null || value === void 0
363+
}
364+
361365
/**
362366
* 检查给定的值是否为奇数
363367
* @param value 要检查的值

src/uni_modules/wot-design-uni/components/wd-cell/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const cellProps = {
4444
/**
4545
* 是否展示边框线
4646
*/
47-
border: Boolean,
47+
border: makeBooleanProp(void 0),
4848
/**
4949
* 设置左侧标题宽度
5050
*/

src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ import { useCell } from '../composables/useCell'
6363
import { useParent } from '../composables/useParent'
6464
import { FORM_KEY } from '../wd-form/types'
6565
import { cellProps } from './types'
66-
import { isDef } from '../common/util'
66+
import { isNone } from '../common/util'
6767
6868
const props = defineProps(cellProps)
6969
const emit = defineEmits(['click'])
7070
7171
const cell = useCell()
7272
7373
const isBorder = computed(() => {
74-
return isDef(cell.border.value) ? cell.border.value : props.border
74+
return Boolean(!isNone(props.border) ? props.border : cell.border.value)
7575
})
7676
7777
const { parent: form } = useParent(FORM_KEY)

0 commit comments

Comments
 (0)