search

Home  >  Q&A  >  body text

javascript - vuejs 用v-for不出来东西,换成v-repeat就好了,求解?

版本 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
})
PHP中文网PHP中文网2818 days ago484

reply all(2)I'll reply

  • 迷茫

    迷茫2017-04-10 16:46:21

    v-for是1.0之后的版本才有的,1.0之前的版本用v-repeat

    reply
    0
  • 黄舟

    黄舟2017-04-10 16:46:21

    1.0 v-for 代替了 v-repeat

    reply
    0
  • Cancelreply