|
@@ -12,8 +12,11 @@
|
|
return {
|
|
return {
|
|
value1: true,
|
|
value1: true,
|
|
value2: true,
|
|
value2: true,
|
|
- value3: '100',
|
|
|
|
- value4: true
|
|
|
|
|
|
+ value3: true,
|
|
|
|
+ value4: true,
|
|
|
|
+ value5: '100',
|
|
|
|
+ value6: true,
|
|
|
|
+ value7: false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -24,14 +27,10 @@
|
|
Switch is used for switching between two opposing states.
|
|
Switch is used for switching between two opposing states.
|
|
|
|
|
|
### Basic usage
|
|
### Basic usage
|
|
-
|
|
|
|
-:::demo Bind `v-model` to a `Boolean` typed variable. You can add `on-text` or `off-text` attribute to show texts when the component is `on` or `off`, respectively. The `on-color` and `off-color` attribute decides the background color in two states.
|
|
|
|
|
|
+:::demo Bind `v-model` to a `Boolean` typed variable. The `on-color` and `off-color` attribute decides the background color in two states.
|
|
|
|
|
|
```html
|
|
```html
|
|
-<el-switch
|
|
|
|
- v-model="value1"
|
|
|
|
- on-text=""
|
|
|
|
- off-text="">
|
|
|
|
|
|
+<el-switch v-model="value1">
|
|
</el-switch>
|
|
</el-switch>
|
|
<el-switch
|
|
<el-switch
|
|
v-model="value2"
|
|
v-model="value2"
|
|
@@ -52,14 +51,45 @@ Switch is used for switching between two opposing states.
|
|
```
|
|
```
|
|
:::
|
|
:::
|
|
|
|
|
|
|
|
+### Text description
|
|
|
|
+:::demo You can add `on-text` and `off-text` attribute to show texts.
|
|
|
|
+
|
|
|
|
+```html
|
|
|
|
+<el-switch
|
|
|
|
+ v-model="value3"
|
|
|
|
+ on-text="Pay by month"
|
|
|
|
+ off-text="Pay by year">
|
|
|
|
+</el-switch>
|
|
|
|
+<el-switch
|
|
|
|
+ style="display: block"
|
|
|
|
+ v-model="value4"
|
|
|
|
+ on-color="#13ce66"
|
|
|
|
+ off-color="#ff4949"
|
|
|
|
+ on-text="Pay by month"
|
|
|
|
+ off-text="Pay by year">
|
|
|
|
+</el-switch>
|
|
|
|
+
|
|
|
|
+<script>
|
|
|
|
+ export default {
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ value3: true,
|
|
|
|
+ value4: true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+</script>
|
|
|
|
+```
|
|
|
|
+:::
|
|
|
|
+
|
|
### Extended value types
|
|
### Extended value types
|
|
|
|
|
|
:::demo You can set `on-value` and `off-value` attributes. They both receive a `Boolean`, `String` or `Number` typed value.
|
|
:::demo You can set `on-value` and `off-value` attributes. They both receive a `Boolean`, `String` or `Number` typed value.
|
|
|
|
|
|
```html
|
|
```html
|
|
-<el-tooltip :content="'Switch value: ' + value3" placement="top">
|
|
|
|
|
|
+<el-tooltip :content="'Switch value: ' + value5" placement="top">
|
|
<el-switch
|
|
<el-switch
|
|
- v-model="value3"
|
|
|
|
|
|
+ v-model="value5"
|
|
on-color="#13ce66"
|
|
on-color="#13ce66"
|
|
off-color="#ff4949"
|
|
off-color="#ff4949"
|
|
on-value="100"
|
|
on-value="100"
|
|
@@ -71,7 +101,7 @@ Switch is used for switching between two opposing states.
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- value3: '100'
|
|
|
|
|
|
+ value5: '100'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -86,13 +116,11 @@ Switch is used for switching between two opposing states.
|
|
|
|
|
|
```html
|
|
```html
|
|
<el-switch
|
|
<el-switch
|
|
- v-model="value4"
|
|
|
|
- on-text=""
|
|
|
|
- off-text=""
|
|
|
|
|
|
+ v-model="value6"
|
|
disabled>
|
|
disabled>
|
|
</el-switch>
|
|
</el-switch>
|
|
<el-switch
|
|
<el-switch
|
|
- v-model="value4"
|
|
|
|
|
|
+ v-model="value7"
|
|
disabled>
|
|
disabled>
|
|
</el-switch>
|
|
</el-switch>
|
|
|
|
|
|
@@ -100,7 +128,8 @@ Switch is used for switching between two opposing states.
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- value4: true
|
|
|
|
|
|
+ value6: true,
|
|
|
|
+ value7: false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -113,11 +142,11 @@ Switch is used for switching between two opposing states.
|
|
Attribute | Description | Type | Accepted Values | Default
|
|
Attribute | Description | Type | Accepted Values | Default
|
|
----| ----| ----| ----|----
|
|
----| ----| ----| ----|----
|
|
disabled | whether Switch is disabled | boolean | — | false
|
|
disabled | whether Switch is disabled | boolean | — | false
|
|
-width | width of Switch | number | — | 58 (with text) / 46 (no text)
|
|
|
|
|
|
+width | width of Switch | number | — | 40
|
|
on-close-icon | class name of the icon displayed when in `on` state, overrides `on-text` | string | — | —
|
|
on-close-icon | class name of the icon displayed when in `on` state, overrides `on-text` | string | — | —
|
|
off-close-icon |class name of the icon displayed when in `off` state, overrides `off-text`| string | — | —
|
|
off-close-icon |class name of the icon displayed when in `off` state, overrides `off-text`| string | — | —
|
|
-on-text | text displayed when in `on` state | string | — | ON
|
|
|
|
-off-text | text displayed when in `off` state | string | — | OFF
|
|
|
|
|
|
+on-text | text displayed when in `on` state | string | — | —
|
|
|
|
+off-text | text displayed when in `off` state | string | — | —
|
|
on-value | switch value when in `on` state | boolean / string / number | — | true
|
|
on-value | switch value when in `on` state | boolean / string / number | — | true
|
|
off-value | switch value when in `off` state | boolean / string / number | — | false
|
|
off-value | switch value when in `off` state | boolean / string / number | — | false
|
|
on-color | background color when in `on` state | string | — | #20A0FF
|
|
on-color | background color when in `on` state | string | — | #20A0FF
|