From b914103920ee4453fda238c5e610c67cf8449ca3 Mon Sep 17 00:00:00 2001 From: castleiMac Date: Mon, 4 Apr 2022 10:05:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=20dropdown=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=B7=BB=E5=8A=A0disabled=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/docs/zh-CN/components/dropdown.md | 32 +++++++++++++++++++++++ src/component/dropdown/index.vue | 8 ++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/example/docs/zh-CN/components/dropdown.md b/example/docs/zh-CN/components/dropdown.md index c6841457..173d9129 100644 --- a/example/docs/zh-CN/components/dropdown.md +++ b/example/docs/zh-CN/components/dropdown.md @@ -80,6 +80,37 @@ export default { } + +::: title 禁用弹出 +::: + +::: demo + + + + + ::: ::: title Dropdown 属性 @@ -90,6 +121,7 @@ export default { | 属性 | 描述 | 可选值 | | ------- | -------- | --------------- | | trigger | 触发方式 | `click` `hover` | +| disabled | 是否禁用触发 | `true` `false` | ::: diff --git a/src/component/dropdown/index.vue b/src/component/dropdown/index.vue index 0dc9dcfc..ccbad16c 100644 --- a/src/component/dropdown/index.vue +++ b/src/component/dropdown/index.vue @@ -12,10 +12,12 @@ import { DropdownTrigger } from "./interface"; export interface LayDropdownProps { trigger?: DropdownTrigger; + disabled?: boolean } const props = withDefaults(defineProps(), { trigger: "click", + disabled: false }); const openState = ref(false); @@ -26,7 +28,8 @@ onClickOutside(dropdownRef, (event) => { }); const open = function () { - openState.value = true; + if (props.disabled === false) + openState.value = true; }; const hide = function () { @@ -34,7 +37,8 @@ const hide = function () { }; const toggle = function () { - openState.value = !openState.value; + if (props.disabled === false) + openState.value = !openState.value; }; provide("openState", openState); From bcb6109246d7e2c7b7cda7ec7723f8145b4196f8 Mon Sep 17 00:00:00 2001 From: castleiMac Date: Mon, 4 Apr 2022 10:05:43 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=20datePicker=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0disabled=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/docs/zh-CN/components/datePicker.md | 28 +++++++++++++++++++++ src/component/datePicker/index.vue | 6 ++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/example/docs/zh-CN/components/datePicker.md b/example/docs/zh-CN/components/datePicker.md index 12419d87..b8a1bacf 100644 --- a/example/docs/zh-CN/components/datePicker.md +++ b/example/docs/zh-CN/components/datePicker.md @@ -62,6 +62,33 @@ export default { ::: +::: title 禁止修改 +::: + +::: demo + + + + + +::: + ::: title 年份选择 ::: @@ -177,6 +204,7 @@ export default { | ------------- | ------------------------------------------------------------ | -------------- | ------ | -------------- | | v-model | 当前时间 | `string` | -- | — | | type | 选择类型 | `string` | `date` | `date` `datetime` `year` `month` `time` `yearmonth` | +| disabled | 是否禁止修改 | `boolean` | false | — | ::: diff --git a/src/component/datePicker/index.vue b/src/component/datePicker/index.vue index 749c6be5..f488c960 100644 --- a/src/component/datePicker/index.vue +++ b/src/component/datePicker/index.vue @@ -1,6 +1,6 @@