From 31353ceafa3bcae01202c40918e579d141957c0a Mon Sep 17 00:00:00 2001 From: Jasper <85024227+jasper-ops@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:00:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20cell=E7=BB=84=E4=BB=B6borde?= =?UTF-8?q?r=E5=B1=9E=E6=80=A7=E4=BB=A5props=E4=B8=BA=E6=9C=80=E9=AB=98?= =?UTF-8?q?=E4=BC=98=E5=85=88=E7=BA=A7=20(#656)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: ✨ cell组件border属性以props为最高优先级 * refactor: ♻️ 替换`??`运算符为更兼容的方式 --- docs/component/cell.md | 3 ++- src/pages/cell/Index.vue | 1 + src/uni_modules/wot-design-uni/components/common/util.ts | 4 ++++ src/uni_modules/wot-design-uni/components/wd-cell/types.ts | 2 +- src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/component/cell.md b/docs/component/cell.md index fbd5183e..e10fdf59 100644 --- a/docs/component/cell.md +++ b/docs/component/cell.md @@ -69,7 +69,8 @@ ```html - + + ``` diff --git a/src/pages/cell/Index.vue b/src/pages/cell/Index.vue index 42b50eaf..d9ce094c 100644 --- a/src/pages/cell/Index.vue +++ b/src/pages/cell/Index.vue @@ -37,6 +37,7 @@ + diff --git a/src/uni_modules/wot-design-uni/components/common/util.ts b/src/uni_modules/wot-design-uni/components/common/util.ts index a638f49f..de23fa91 100644 --- a/src/uni_modules/wot-design-uni/components/common/util.ts +++ b/src/uni_modules/wot-design-uni/components/common/util.ts @@ -358,6 +358,10 @@ export function isNotUndefined(value: T): value is NotUndefined { return !isUndefined(value) } +export function isNone(value: any): value is null | undefined { + return value === null || value === void 0 +} + /** * 检查给定的值是否为奇数 * @param value 要检查的值 diff --git a/src/uni_modules/wot-design-uni/components/wd-cell/types.ts b/src/uni_modules/wot-design-uni/components/wd-cell/types.ts index 4f61d508..7b9e6e05 100644 --- a/src/uni_modules/wot-design-uni/components/wd-cell/types.ts +++ b/src/uni_modules/wot-design-uni/components/wd-cell/types.ts @@ -44,7 +44,7 @@ export const cellProps = { /** * 是否展示边框线 */ - border: Boolean, + border: makeBooleanProp(void 0), /** * 设置左侧标题宽度 */ diff --git a/src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue b/src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue index 7b2fec30..dd36ba67 100644 --- a/src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue +++ b/src/uni_modules/wot-design-uni/components/wd-cell/wd-cell.vue @@ -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)