Vuejs 的表单复选框(type = "checkbox") 单选框(type = "radio")

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<script src="https://unpkg.com/vue/dist/vue.js"></script>

<title>Document</title>

</head>

<body>

扫描二维码关注公众号,回复: 4548802 查看本文章

<div id = "myApp">

<h1>表单复选框</h1>

<input type="checkbox" id="生化危机" value="生化危机" v-model= "checkedGames" > <!--这里的type = "checkbox"为input输入框的一种打钩属性 -->

<label for="生化危机7">生化危机7</label> <!--使用 label "for" 属性 绑定到 input "id"属性上 -->

<input type="checkbox" id="模拟飞行" value="模拟飞行" v-model= "checkedGames" >

<label for="模拟飞行">模拟飞行</label> <!--v-mode为绑定的数组元素-->

<input type="checkbox" id="塞尔达传说" value="塞尔达传说" v-model= "checkedGames" >

<label for="萨尔达传说">塞尔达传说</label> <!--这里的value为v-model绑定所传的值-->

<br>

<p>Game is :{{checkedGames}}</p>

</div>

<script>

var myApp = new Vue({

el:"#myApp",

data:{

checkedGames: [] //这里的checkedGames为一个data数组

},

});

</script>

</body>

</html>

猜你喜欢

转载自blog.csdn.net/xlh006/article/details/83618829