|
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 | 6 | <meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7 | 7 | <title>뷰 기초 익히기</title>
|
8 |
| - <style> |
9 |
| - .red { |
10 |
| - color: red; |
11 |
| - } |
12 |
| - |
13 |
| - .font-bold { |
14 |
| - font-weight: bold; |
15 |
| - } |
16 |
| - </style> |
17 | 8 | <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
18 | 9 | </head>
|
19 | 10 | <body>
|
20 | 11 | <div id="app">
|
21 |
| - <div> |
22 |
| - {{ people[0].name }} {{ people[0].age }} |
23 |
| - </div> |
24 |
| - <div> |
25 |
| - {{ people[1].name }} {{ people[1].age }} |
26 |
| - </div> |
27 |
| - <div> |
28 |
| - {{ people[2].name }} {{ people[2].age }} |
29 |
| - </div> |
30 |
| - <div> |
31 |
| - {{ people[3].name }} {{ people[3].age }} |
32 |
| - </div> |
33 |
| - |
34 |
| - <hr> |
35 |
| - |
36 |
| - <div v-for="(person, index) in people" :key="person.id"> |
37 |
| - {{ person.name }} {{ person.age }} {{ index }} |
38 |
| - </div> |
| 12 | + {{ name }}<br> |
| 13 | + <button @click="changeText">Click</button> |
| 14 | + </div> |
| 15 | + <div id="app-1"> |
| 16 | + {{ name }}<br> |
| 17 | + <button @click="changeText">Click</button> |
39 | 18 | </div>
|
40 | 19 | <script>
|
41 |
| - new Vue({ |
| 20 | + const app = new Vue({ |
42 | 21 | el: '#app',
|
43 | 22 | data: {
|
44 |
| - people: [ |
45 |
| - { id: 1, name: 'a', age: 20 }, |
46 |
| - { id: 2, name: 'b', age: 21 }, |
47 |
| - { id: 3, name: 'c', age: 22 }, |
48 |
| - { id: 4, name: 'd', age: 23 }, |
49 |
| - { id: 5, name: 'e', age: 24 }, |
50 |
| - { id: 6, name: 'e', age: 25 }, |
51 |
| - ] |
| 23 | + name: 'kossie' |
| 24 | + }, |
| 25 | + methods: { |
| 26 | + changeText() { |
| 27 | + app1.name = 'kossie updated'; |
| 28 | + } |
| 29 | + }, |
| 30 | + }) |
| 31 | + |
| 32 | + const app1 = new Vue({ |
| 33 | + el: '#app-1', |
| 34 | + data: { |
| 35 | + name: 'kossie1' |
52 | 36 | },
|
53 | 37 | methods: {
|
54 |
| - |
| 38 | + changeText() { |
| 39 | + app.name = 'kossie1 updated'; |
| 40 | + } |
55 | 41 | },
|
56 | 42 | })
|
57 | 43 | </script>
|
|
0 commit comments