知识点
- 支持三种类型:变量、数组、对象,访问方式与JavaScript语法相同。
完整代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lesson 2 data 数据对象</title>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.js"></script>
</head>
<body>
<div id="app">
<p>{{ message }}</p>
<span>{{info.name}}</span>
<span>{{info.age}}</span>
<ul>
<li>{{list[0]}}</li>
<li>{{list[1]}}</li>
<li>{{list[2]}}</li>
<li>{{list[3]}}</li>
</ul>
</div>
<script>
let tmp = new Vue({
el: "#app",
data: {
"message": "Hello Vue",
"info": {
name: "Vue",
age: 18
},
"list": ["tencent", "alibaba", "baidu", "netease"]
}
})
</script>
</body>
</html>