We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3cd2fbe commit 83ad136Copy full SHA for 83ad136
src/components/SwitchDemo.vue
@@ -1,6 +1,6 @@
1
<template>
2
<div>
3
- <Switch :value="y" @input="y = $event" />
+ <Switch v-model:value="y" />
4
</div>
5
</template>
6
<script lang="ts">
src/lib/Switch.vue
@@ -7,9 +7,11 @@ export default {
7
props:{
8
value:Boolean
9
},
10
+ // props和context 传值方式
11
setup(props,context){
12
const toggle = ()=>{
- context.emit('input', !props.value)
13
+ // 事件:vue3的v-model改动,之前是input
14
+ context.emit('update:value', !props.value)
15
}
16
return { toggle }
17
0 commit comments