简体   繁体   中英

vue execute @click after v-model

I have a checkbox with a state based on todo.complete todo.save() persists the current complete value to the database. However @click seems to be triggered before the v-model binding updates todo.complete

  <v-checkbox v-model="todo.complete" @click="todo.save()" :label="todo.title" />

I have to do it like this to make it work:

  <v-checkbox v-model="todo.complete" @click="todo.complete = !todo.complete; todo.save()" :label="todo.title" />

Is there some way to execute todo.save() after v-model has been updated. something like @click.after

请尝试使用change事件:

<v-checkbox v-model="todo.complete" @change="todo.save()" :label="todo.title" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM