Vue —— JS对象迭代
-
v-for
循环JS对象,把对象内容循环显示到页面上
<!DOCTYPE html>
<html>
<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>for.html</title>
<script src="../js/vue.js"></script>
<link type='text/css' rel='styleSheet' href='../css/style.css' >
</head>
<body>
<div id="example">
<!-- 先拿值,再拿索引 -->
<div v-for="(value, key) in games">{{key}} : {{value}}</div>
</div>
</body>
<script>
new Vue({
el: '#example',
data: {
//games是字典一样的东西
games: {
title: "乌贼娘2代",
price: 350,
pubdate: "2017年夏季",
category: "射击",
agerange: "全年龄",
},
},
});
</script>
</html>

浙公网安备 33010602011771号