<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Vue.js自学:循环和遍历数组+列表的展示</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<ul>
<li v-for="item in movies">{{item}}</li>
</ul>
</div>
</body>
<script type="text/javascript">
//JS中数组写法和PHP一致,为[‘arr’,’arr’]
//const是常量的意思,JS/ES8中不建议使用Var 建议使用let定义变量
//el是绑定的意思
//v-for是循环遍历数组的意思
//核心写法:item in arr_name
//遍历结果为{{item}}
const app = new Vue({
el: ‘#app’,
data: {
message: ‘这只是一个基础的信息’,
movies: [‘海贼王’,’火影忍者’,’全职猎人’,’七龙珠’]
}
})
</script>
</html>