1、vue官方文档如下:
vue官方文档链接
2、vue程序
<!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">
<h>{{message}}</h>
</div>
<script src="vue.js"></script>
<script>
//let(变量) const(常量)
//编程范式:声明式编程
const app = new new Vue({
el: '#app', //用于挂载要管理的元素
data: {
//定义数据
message: 'hello,vue!',
},
})()
</script>
</body>
</html>
3、创建Vue对象,传入的一些options:
(1){}中包含el属性:该属性决定了这个Vue对象挂载到哪个元素上,明显,这里挂载到id为app的元素上
(2){}包含了data属性:该属性中常会存储一些数据
- 这些数据可以使我们直接定义出来的
- 也可能来自网络,从服务器中加载的
4、浏览器执行代码过程
(1)执行html中的代码
网页展示: hello,vue!
(2)在控制台中设置“app.message=baby”后
网页展示:baby