Home  >  Article  >  Web Front-end  >  Regarding the problem of two-way binding of Vue form demo v-model

Regarding the problem of two-way binding of Vue form demo v-model

不言
不言Original
2018-06-30 16:37:011395browse

This article introduces you to the Vue form demo v-model two-way binding problem through example code. The code is simple and easy to understand, which is very good and has certain reference value. Friends in need can refer to the specific code

As shown below:

<p id="app">
 <textarea v-model = "message" placeholer = &#39;请在此输入文字&#39;></textarea>
 <span>{{message}}</span>
  </br>
 <input type="text" v-model="data.name"/>
 <span>姓名:{{data.name}}</span>
 </br>
 <input type="radio" id="boy" value="男" v-model="data.gender"/>
 <label for="boy">男</label>
 <input type="radio" id="girl" value="女" v-model="data.gender"/>
 <lable for="girl">女</lable>
 <span>{{data.gender}}</span>
 <br/>
 <input type="checkbox" id="item1" value="阅读" v-model="data.interest"/>
 <lable for="item1">阅读</lable>
 <input type="checkbox" id="item2" value="打球" v-model="data.interest"/>
 <lable for="item2">打球</lable>
 <input type="checkbox" id="item3" value="体操" v-model="data.interest"/>
 <lable for="checkbox">体操</lable>
 <br/>
 <span>{{data.interest}}</span>
 <select v-model="data.identity">
  <option value="java" selected>java</option>
  <option value="web">web</option>
  <option value="hr">hr</option>
 </select>
 <span>身份:{{data.identity}}</span>
</p>
<script src="js/vue.js"></script>
<script>
 new Vue({
  el: &#39;#app&#39;,
  data: {
   message: &#39;6&#39;,
   data: {
    name: &#39;&#39;,
    gender: &#39;&#39;,
    interest: [],
    identity: &#39;&#39;
   },
  }
 })
</script>

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

About the method of Vue2 SSR caching Api data

About VUE-region selector (V- Introduction to the use of Distpicker) component

The above is the detailed content of Regarding the problem of two-way binding of Vue form demo v-model. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn