Skip to content

Commit 20d8651

Browse files
committed
add data to toggle
1 parent 4e786ce commit 20d8651

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@impvis/components",
3-
"version": "1.1.9",
3+
"version": "1.2.0",
44
"license": "BSD-3-Clause",
55
"main": "./dist/impvis-components.js",
66
"unpkg": "./dist/impvis-components.umd.js",

src/components/ToggleBasic/ToggleBasic.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,29 @@ export default {
2525
props: {
2626
value:{
2727
type: Boolean,
28-
required: true
28+
default: false
29+
}
30+
},
31+
data(){
32+
return{
33+
toggleValue: this.value
2934
}
3035
},
3136
computed: {
3237
backgroundStyles() {
3338
return {
34-
'switchedOn': this.value,
35-
'switchedOff': !this.value
39+
'switchedOn': this.toggleValue,
40+
'switchedOff': !this.toggleValue
3641
};
3742
},
3843
indicatorStyles() {
39-
return { transform: this.value ? 'translateX(14px)' : 'translateX(0)' };
44+
return { transform: this.toggleValue ? 'translateX(14px)' : 'translateX(0)' };
4045
}
4146
},
4247
methods: {
4348
toggle() {
44-
this.value =! this.value
45-
this.$emit('input', !this.value);
49+
this.toggleValue =! this.toggleValue
50+
this.$emit('input', !this.toggleValue);
4651
}
4752
}
4853
};

0 commit comments

Comments
 (0)