<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <div id="app"> <ol> <todo-item v-for="item in groceryList" :todo="item"></todo-item> </ol> </div> <script src="js/vue.js" type="text/javascript" charset="utf-8"></script> <script src="js/vue.component.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> var vm = new Vue({ el: '#app', data: { groceryList: [ {text: 'xudongyang'}, {text: 'lengpengfei'} ] } }); </script> </body> </html>
Vue.component('todo-item',{ props: ['todo'], template: '<li>{{todo.text}}</li>' });