修复v-model数据未同步问题
This commit is contained in:
@@ -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)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user