search

Home  >  Q&A  >  body text

javascript - Why can vue checkbox be written like this?

<input type="checkbox" name="test_checkbox" :checked1111="test" @click="onClick"> Test
onClick: function (e) {
        
          this.test = e.target.checked
          console.log(this.test)
        
      }

You can write whatever you want in checked1111. Strangely enough, the check function can be realized
or written as

<input type="checkbox" name="test_checkbox" :aaafc="test" @click="onClick"> Test

can realize two-way binding of data test

曾经蜡笔没有小新曾经蜡笔没有小新2751 days ago532

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-19 10:12:52

    Because what works is your onClick processing function, you bind whether checked to test in this function, so it is okay if you do not write: checked="test" on the input tag.

    reply
    0
  • Cancelreply