·练习常见操作:

    ·通过v-for创建组件

    <!DOCTYPE html> <html lang=“en”> <head> <meta charset=“UTF-8”> <meta name=“viewport” content=“width=device-width, initial-scale=1.0”> <title>Document</title> </head> <body> <div id=“app”> <demo-item v-for=“item in items” :item-title=“item.title” :item-content=“item.content” :key=“item.title” :item=“item” ></demo-item> </div> <script src=“lib/vue.js”></script> <script> Vue.component(‘demoItem’, { props: [‘itemTitle’, ‘itemContent’, ‘item’], template: `

    {{ itemTitle }}

    {{ itemContent }}

    ` }) new Vue({ el: ‘#app’, data: { // 准备给子组件使用的数据 items: [ { title: ‘示例标题1’, content: ‘示例内容1’ }, { title: ‘示例标题2’, content: ‘示例内容2’ }, { title: ‘示例标题3’, content: ‘示例内容3’ }, ] } }) </script> </body> </html>