P6 Vue双向绑定 v-model
<!DOCTYPE html><meta charset="UTF-8" xmlns:v-on="http://www.w3.org/1999/xhtml"><title>Title</title></head><body><!--view层 模板--><div id="app">...
·
<!DOCTYPE html>
<meta charset="UTF-8" xmlns:v-on="http://www.w3.org/1999/xhtml">
<title>Title</title>
</head>
<body>
<!--view层 模板-->
<div id="app">
请输入:<input v-model="message">
<p>{{message}}</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var vm = new Vue({
el:"#app",
data:{
message:''
}
});
</script>
</body>
</html>
提供一个空值为禁用选项
<!DOCTYPE html>
<meta charset="UTF-8" xmlns:v-on="http://www.w3.org/1999/xhtml">
<title>Title</title>
</head>
<body>
<!--view层 模板-->
<div id="app">
<!-- 请输入:<input v-model="message">
<p>{{message}}</p>-->
<select v-model="selected">
<option value="" disabled>--请选择--</option>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<p>选择了:{{selected}}</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var vm = new Vue({
el:"#app",
data:{
selected:''
}
});
</script>
</body>
</html>
更多推荐
已为社区贡献3条内容
所有评论(0)