Vue.js—Difference between v-model and v-bind

前端 未结 5 777
小蘑菇
小蘑菇 2020-11-27 08:54

I\'m learning Vue with an online course and the instructor gave me an exercise to make an input text with a default value. I completed it using v-model but, the instructor c

5条回答
  •  迷失自我
    2020-11-27 09:33

    v-model
    it is two way data binding, it is used to bind html input element when you change input value then bounded data will be change.

    v-model is used only for HTML input elements

    ex:  
    

    v-bind
    it is one way data binding,means you can only bind data to input element but can't change bounded data changing input element. v-bind is used to bind html attribute
    ex:

     click me 
    

提交回复
热议问题