javascript - vue official documentation explanation of v-model binding value
怪我咯
怪我咯 2017-06-12 09:22:58
0
1
623

But sometimes we want to bind value to a dynamic property of the Vue instance. In this case, we can use v-bind to achieve this, and the value of this property does not need to be a string.

Question:
1. Explain the above paragraph in detail
2. Combine the following codes to write a complete demo

Checkbox

 // 当选中时 vm.toggle === vm.a // 当没有选中时 vm.toggle === vm.b

single button

 // 当选中时 vm.pick === vm.a

Select List Settings

 // 当选中时 typeof vm.selected // -> 'object' vm.selected.number // -> 123
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (1)
世界只因有你

It refers to the value of radio, checkbox or select options, which can be a static string or instance attributes such as instance data and calculated attributes.

In fact, the following example has been given in detail:
When the user clicks the radio, vm.picked is the character String "a", and, when the user selects, vm.pick is the instance attribute of vm.a .

The select list example is also easy to understand.

In fact, if you type the code and run it yourself, you will almost understand it. However, when typing the code, there may be some error messages (if there is no instance data of a, it will prompt that the bound data is not declared. At this time, in the data Just add an a to it). The thing about Vue that is not very friendly to Chinese learners is that the error prompts in its console are all in English. Some children who are afraid of English may be put off.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!