12345678910111213141516171819202122232425262728293031323334353637 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <title></title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script src="https://unpkg.com/vue/dist/vue.js"></script>
- <link href="../css/style.css" rel="stylesheet"> </head>
- <body>
- <div id="myApp">
- <ol>
- <game-item v-for="item in games" v-bind:game="item"></game-item>
- </ol>
- </div>
- <script>
- /* 组件定义:game-item */
- Vue.component('game-item', {
- props: ['game'],
- template: '<li>{{ game.title }}</li>'
- });
- /* Vue对象实例化 */
- var myApp = new Vue({
- el: '#myApp',
- data: {
- games: [
- { title: '斗地主' },
- { title: '打麻雀' },
- { title: 'UNO' }
- ]
- }
- });
- </script>
- </body>
- </html>
|