<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>v-for</title>
<script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
<h1>v-for</h1>
<hr>
<div id="app">
<ul>
<li v-for="item in sortItems">{{item}}</li>
</ul>
<hr>
<ul>
<li v-for="oi in students">名字叫:{{oi.name}},年龄:{{oi.age}}</li>
</ul>
</div>
</body>
</html>
<script>
var app = new Vue({
el:'#app',
data:{
items:[123,231,3123,2313,213,21312,1111],
students:[
{name:'json',age:'24'},
{name:'Panda',age:'18'},
{name:'PanPan',age:'13'},
]
},
computed:{
sortItems:function(){
return this.items.sort();
}
}
})
</script>