<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>绑定值</title>
</head>
<body>
<!--自动识别最新稳定版本的Vue.js-->
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<!--单选按钮-->
<div id="app">
<input type="radio" v-model="picked" :value="value">
<label>单选按钮</label>
<p>{{ picked }}</p>
<p>{{ value }}</p>
</div>
<!--复选框:-->
<div id="app2">
<input type="checkbox" v-model="toggle" :true-value="value1" :false-value="value2">
<label>复选框</label>
<p>{{ toggle }}</p>
<p>{{ value1 }}</p>
<p>{{ value2 }}</p>
</div>
<!--选择列表-->
<div id="app3">
<select v-model="selected">
<option :value="{ number: 123 }">123</option>
</select>
</div>
<script>
var app = new Vue({
el:'#app',
data:{
picked:false,
value:123
}
})
</script>
<script>
var app = new Vue({
el:'#app2',
data:{
toggle:false,
value1: 'a',
value2: 'b'
}
})
</script>
<script>
var app = new Vue({
el:'#app3',
data:{
selected:''
}
})
</script>
</body>
</html>
绑定值.png
网友评论