From 1e9f693e76817401db8dfbdf3a9a2af91097dd61 Mon Sep 17 00:00:00 2001 From: koory1st <32436334@qq.com> Date: Tue, 5 Mar 2024 20:13:39 +0800 Subject: [PATCH] fix(switch): disabled bug --- docs/src/lib/i18n/zh/switch.js | 2 ++ docs/src/routes/component/switch/+page.svelte | 14 ++++++++++++++ packages/switch/src/lib/switch.svelte | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/src/lib/i18n/zh/switch.js b/docs/src/lib/i18n/zh/switch.js index e56dc8c..3be7aae 100644 --- a/docs/src/lib/i18n/zh/switch.js +++ b/docs/src/lib/i18n/zh/switch.js @@ -15,4 +15,6 @@ export default { cswitch06010: '扩展的 value 类型', cswitch06020: '你可以设置 activeValue 和 inactiveValue 属性, 它们接受 Boolean、String 或 Number 类型的值。', + cswitch07010: '禁用状态', + cswitch07020: '设置disabled属性,接受一个Boolean,设置true即可禁用。', }; diff --git a/docs/src/routes/component/switch/+page.svelte b/docs/src/routes/component/switch/+page.svelte index 6aeacf7..be4ad26 100644 --- a/docs/src/routes/component/switch/+page.svelte +++ b/docs/src/routes/component/switch/+page.svelte @@ -10,6 +10,7 @@ let value2 = true; let value3 = '100'; + let value4 = true;

{$langFn('cswitch01010')}

@@ -144,5 +145,18 @@ +

{$langFn('cswitch07010')}

+

{$langFn('cswitch07020')}

+ + + +`} +> + + + + diff --git a/packages/switch/src/lib/switch.svelte b/packages/switch/src/lib/switch.svelte index 5852637..42c0cb7 100644 --- a/packages/switch/src/lib/switch.svelte +++ b/packages/switch/src/lib/switch.svelte @@ -32,7 +32,7 @@ $: isControlled = value !== false; $: actualValue = value; $: checked = actualValue === activeValue; - $: switchDisabled = loading; + $: switchDisabled = loading || disabled; $: switchKls = a2s([ 'svel-switch', ['is-checked', checked],