+
diff --git a/packages/opendesign/src/components/switch/__demo__/IndexSwitch.vue b/packages/opendesign/src/components/switch/__demo__/IndexSwitch.vue
index 4123a14580982d461dc1c55f04465f8a31f37e25..6bfadeb39c437e14abb8d00699928eb39bcfc3ea 100644
--- a/packages/opendesign/src/components/switch/__demo__/IndexSwitch.vue
+++ b/packages/opendesign/src/components/switch/__demo__/IndexSwitch.vue
@@ -1,23 +1,16 @@
-
Shape
-
- Size
-
- Disabled & Loading
+
- 阻止切换
- 插槽
diff --git a/packages/opendesign/src/components/switch/__demo__/SwitchBeforeChange.vue b/packages/opendesign/src/components/switch/__demo__/SwitchBeforeChange.vue
index d7b2d4da2e9727ae2208ccc3a34d5df9336343fa..68ed61f266fc49671579880232998dee2d689dad 100644
--- a/packages/opendesign/src/components/switch/__demo__/SwitchBeforeChange.vue
+++ b/packages/opendesign/src/components/switch/__demo__/SwitchBeforeChange.vue
@@ -4,33 +4,29 @@ import { OSWitch } from '../index';
const switchVal1 = ref(false);
const loading1 = ref(false);
+let cnt = 0;
const beforeChange1 = (): Promise
=> {
loading1.value = true;
-
+ cnt += 1;
return new Promise((resolve) => {
setTimeout(() => {
loading1.value = false;
- return resolve(true);
+ return resolve(cnt % 2 === 0);
}, 1000);
});
};
const switchVal2 = ref(true);
-const loading2 = ref(false);
-const beforeChange2 = (): Promise => {
- loading2.value = true;
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- loading2.value = false;
- return reject(new Error('Error'));
- }, 1000);
- });
+const beforeChange2 = () => {
+ cnt += 1;
+ return cnt % 2 === 0;
};
+ 阻止切换
diff --git a/packages/opendesign/src/components/switch/__demo__/SwitchDisabledAndLoading.vue b/packages/opendesign/src/components/switch/__demo__/SwitchDisabledAndLoading.vue
index 29967256f1076e21c96894d20187afa27a2bcc51..84454288fa8f56436dbe565d2de32c2d4558e7ea 100644
--- a/packages/opendesign/src/components/switch/__demo__/SwitchDisabledAndLoading.vue
+++ b/packages/opendesign/src/components/switch/__demo__/SwitchDisabledAndLoading.vue
@@ -6,8 +6,9 @@ const switchVal2 = ref(true);
+ Disabled & Loading
diff --git a/packages/opendesign/src/components/switch/__demo__/SwitchShape.vue b/packages/opendesign/src/components/switch/__demo__/SwitchShape.vue
index ee40f473b27fc54078279a889ffa8acbd20513c3..ea2d8dabf644cb916c2426a002b40d2c80ccf86b 100644
--- a/packages/opendesign/src/components/switch/__demo__/SwitchShape.vue
+++ b/packages/opendesign/src/components/switch/__demo__/SwitchShape.vue
@@ -7,7 +7,7 @@ const switchVal2 = ref(true);
diff --git a/packages/opendesign/src/components/switch/__demo__/SwitchSize.vue b/packages/opendesign/src/components/switch/__demo__/SwitchSizeShape.vue
similarity index 65%
rename from packages/opendesign/src/components/switch/__demo__/SwitchSize.vue
rename to packages/opendesign/src/components/switch/__demo__/SwitchSizeShape.vue
index 788ee383f171cee539320468c14b3edbb9412c8f..4663c2bb4a6c8e2896ebedd53ce6022d573ba740 100644
--- a/packages/opendesign/src/components/switch/__demo__/SwitchSize.vue
+++ b/packages/opendesign/src/components/switch/__demo__/SwitchSizeShape.vue
@@ -6,10 +6,14 @@ const switchVal2 = ref(true);
+ Size
+
+ Round
-
-
-
diff --git a/packages/opendesign/src/components/switch/__demo__/SwitchSlots.vue b/packages/opendesign/src/components/switch/__demo__/SwitchSlots.vue
index 133e81b00c52dd86c7f2f6fee5d34baf8409b7f3..f96d607cb2062301811aff63f2139640ae0950e7 100644
--- a/packages/opendesign/src/components/switch/__demo__/SwitchSlots.vue
+++ b/packages/opendesign/src/components/switch/__demo__/SwitchSlots.vue
@@ -8,13 +8,14 @@ const switchVal2 = ref(true);
+ 插槽
-
+
开
关
-
+
diff --git a/packages/opendesign/src/components/switch/style/index.scss b/packages/opendesign/src/components/switch/style/index.scss
index 507f2c21163c77c2cb9f7c7a0cf6c5e8fb217a9d..df3d321c86f46a389a7f51a6545159d684016ae7 100644
--- a/packages/opendesign/src/components/switch/style/index.scss
+++ b/packages/opendesign/src/components/switch/style/index.scss
@@ -7,7 +7,7 @@
color: var(--switch-color);
transition: all 0.3s;
cursor: pointer;
-
+ // TODO 以o-xxx的类 不需要嵌套,尽量减少嵌套
.o-switch-wrapper {
width: 100%;
height: 100%;
@@ -116,6 +116,7 @@
.o-switch-wrapper {
font-size: var(--switch-text-size-l);
+ // TODO
line-height: --switch-text-height-l;
.o-switch-handler {
width: 20px;