File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <Switch />
3
+ <Switch :value = " y " @input = " y = $event " />
4
4
</div >
5
5
</template >
6
6
<script lang="ts">
7
7
import Switch from " ../lib/Switch.vue"
8
+ import {ref } from ' vue' ;
8
9
export default {
9
- components:{ Switch }
10
+ components:{ Switch },
11
+ setup(){
12
+ const y = ref (false )
13
+ return { y }
14
+ }
10
15
}
11
16
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <button @click =" toggle" :class =" {checked}" > <span ></span > </button >
2
+ <button @click =" toggle" :class =" {checked:value}" > <span ></span > </button >
3
+ <div >{{ value }}</div >
3
4
</template >
4
5
<script lang="ts">
5
- import { ref } from ' vue'
6
6
export default {
7
- setup(){
8
- const checked = ref (true )
7
+ props:{
8
+ value:Boolean
9
+ },
10
+ setup(props ,context ){
9
11
const toggle = ()=> {
10
- checked . value = ! checked .value
12
+ context . emit ( ' input ' , ! props .value )
11
13
}
12
- return { checked , toggle }
14
+ return { toggle }
13
15
}
14
16
}
15
17
</script >
@@ -23,6 +25,7 @@ button{
23
25
background : grey ;
24
26
border-radius : $h / 2 ;
25
27
position : relative ;
28
+ cursor : pointer ;
26
29
}
27
30
span {
28
31
position : absolute ;
You can’t perform that action at this time.
0 commit comments