代码:
<!DOCTYPE html>
<html>
<head>
<title>v-model双向数据绑定</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
<div id="app">
输入部分:
<input type="text" class="form-control col-6 mb-5 mt-3" v-model="message">
输出部分:
<div class="mt-3">{{message}}</div>
</div>
</div>
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
var 自定义 = new Vue({
el: '#app',
data: {
message:"我在学习vue"
},
methods:{
}
})
</script>
</body>
</html>
效果: