Setting a checkbox as checked with Vue.js

前端 未结 5 1947
清歌不尽
清歌不尽 2020-12-13 09:21

I have been googling and playing with every combination I know but I cannot get my checkboxes to be initialised as checked.

Example:

5条回答
  •  抹茶落季
    2020-12-13 10:11

    Let's say you want to pass a prop to a child component and that prop is a boolean that will determine if the checkbox is checked or not, then you have to pass the boolean value to the v-bind:checked="booleanValue" or the shorter way :checked="booleanValue", for example:

    
    

    That should work and the checkbox will display the checkbox with it's current boolean state (if true checked, if not unchecked).

提交回复
热议问题