首页 > 代码库 > vue学习笔记三:常见的表单绑定

vue学习笔记三:常见的表单绑定

<template>
    <div id="app">
        <input type="checkbox" id="checked" v-model="checked"/>
        <label for="checked">{{checked}}</label><br />
        <input type="checkbox" id="jack" value="http://www.mamicode.com/jack" v-model="names" />
        <label for="jack">jack</label>
        <input type="checkbox" id="sim" value="http://www.mamicode.com/sim" v-model="names" />
        <label for="sim">sim</label>
        <input type="checkbox" id="tom" value="http://www.mamicode.com/tom" v-model="names" />
        <label for="tom">tom</label>
        <input type="checkbox" id="mei" value="http://www.mamicode.com/mei" v-model="names" />
        <label for="mei">mei</label>
        <p>{{names}}</p>
        <input type="radio" id="male" value="http://www.mamicode.com/male" v-model="gender" />
        <label for="male">male</label>
        <input type="radio" id="female" value="http://www.mamicode.com/female" v-model="gender" />
        <label for="female">female</label>
        <p>{{gender}}</p>
        <select name="choose" id="choose" v-model="choose">
            <option value="" disabled="">please select</option>
            <option value="http://www.mamicode.com/grade one">grade one</option>
            <option value="http://www.mamicode.com/grade two">grade two</option>
            <option value="http://www.mamicode.com/grade third">grade third</option>
        </select>
        <p><label for="choose">{{choose}}</label></p>
    </div>
</template>

<script>
    export default {
        name: ‘app‘,
        data() {
            return {
                checked : false,
                names : [],
                gender : "",
                choose : "",
            }
        }
    }
    
</script>

 

vue学习笔记三:常见的表单绑定