1)第一步
创建html页面,使用vscode快捷键生成html代码 !
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
2)第二步引入vue的js文件,类似于jquery
<body>
<script src="vue.min.js"></script>
</body>
3)第三步在html页面创建div标签,div添加id属性
<div id="app"></div>
4)第四步编写vue代码,固定的结构
<body>
<script>
//创建一个vue对象
new Vue({
el: '#app',//绑定vue作用的范围
data:{//定义页面中显示的数据模型
message: 'Hello Vue!'
}
})
</script>
</body>
5) 使用插值表达式
获取data里的定义值
{{名称}}
最后得出的结构
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
{{message}}
</div>
<script src="vue.min.js"></script>
<script>
//创建一个vue对象
new Vue({
el: '#app',//绑定vue作用的范围
data:{//定义页面中显示的数据模型
message: 'Hello Vue!'
}
})
</script>
</body>
</html>