1. 主页
  2. 文档
  3. vue2 dcloud
  4. 第9节 列表渲染

第9节 列表渲染

第9节 列表渲染

	<div v-for="items,index in items" :key="index">
		{{index}} {{items.message}}
	</div>
	
	<div v-for="value,key in object">
		{{key}}{{value}}
	</div>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="vue.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>

<div id="app">
	<ul>
		<li v-for="item,index in items" :key="index">
		{{index}}{{ item.message }}
		</li>
	</ul>
	<ul>
		<li v-for="value, key in object">
			{{key}} : {{ value }}
		</li>
	</ul>
</div>
<script type="text/javascript">
var vm = new Vue({
	el : "#app",
	data : {
		items : [
			{ message: 'Foo' },
			{ message: 'Bar' }
		],
		object: {
			title: 'How to do lists in Vue',
			author: 'Jane Doe',
			publishedAt: '2016-04-10'
		}
	}
});

</script>

</body>
</html>
这篇文章对您有用吗?

我们要如何帮助您?