版本 Vue.js v0.12.16
报如下错误: [Vue warn]: Failed to resolve directive: for
把 v-for="book in books"
换成 v-repeat="book:books"
就是好的。
Html:
<table class="table">
<tr v-for="book in books">
<td>{{book.id}}</td>
<td>{{book.name}}</td>
<td>{{book.author}}</td>
<td>{{book.price}}</td>
</tr>
</table>
Js:
var datas = {
book: {
id: 0,
name: '',
author: '',
price: ''
},
books: [{
id: 1,
author: '曹雪芹',
name: '红楼梦',
price: 32.0
}, {
id: 2,
author: '施耐庵',
name: '水浒传',
price: 30.0
}]
}
var vm = new Vue ({
el: '#bookapp',
data: datas
})