(尚002)Vue的基本使用

输入端在上面变化的同时,下面的内容也在变

 1.test.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>01_HelloWorld</title>
</head>
<body>
<!--
1.引入vue.js
2.创建Vue对象
el:指定根element(选择器)
data:初始化数据(页面可以访问)
3.双向数据绑定: v-model
4.显示数据:{{}}
5.理解vue的mvvm实现
-->
<div id="app"> <!--view-->
<input type="text" v-model="username">
<p>Hello {{username}}</p>
</div>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript">
//创建Vue实例
const vm=new Vue({//配置对象 option
el:'#app',//element:选择器
data:{//数据(model)
username:'赵云'
}
})
</script>
</body>
</html>

 2.页面展示

 

 

 厉害了!!!

猜你喜欢

转载自www.cnblogs.com/curedfisher/p/12009731.html