diff --git a/components/my-components/my-tabs.vue b/components/my-components/my-tabs.vue index 6f56623..9a5d15d 100644 --- a/components/my-components/my-tabs.vue +++ b/components/my-components/my-tabs.vue @@ -42,7 +42,6 @@ import { computed, ref, watch } from 'vue'; let current=ref(props.modelValue||props.defaultIndex||0) function changeCurrent(index){ current.value=index - emit('update:modelValue',index) } const computedBlockStyle=computed(()=>{ const oneWidth= 100/props.list.length @@ -52,8 +51,12 @@ import { computed, ref, watch } from 'vue'; left:left+'%' } }) - watch(()=>current.value,()=>{ - emit('change',current.value) + watch(()=>props.modelValue,(newval)=>{ + current.value=newval + }) + watch(()=>current.value,(newval)=>{ + emit('update:modelValue',newval) + emit('change',newval) })