1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.2/dist/vue.js"></script>
    <title></title>
</head>
 
<body>
    <div id="app">
        {{ name }}
        <button @click="changeText">Click</button>
    </div>
    
    <div id="app-1">
        {{ name }}
        <button @click="changeText">Click</button>
    </div>
 
    <script>
        new Vue({
            el: '#app',
            data: {
                name : 'koko'
            },
            methods: {
                changeText(){
                    this.name = 'kossie updated'
                }
 
            }
 
        });
 
        new Vue({
            el: '#app-1',
            data: {
                name : 'koko1'
            },
            methods: {
                changeText(){
                    this.name = 'kossie1 updated'
                }
 
            }
 
        });
    </script>
</body>
 
</html>
cs


각 인스턴스에 접근을 할 수 가 없을 것이다.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<body>
    <div id="app">
        {{ name }}
        <button @click="changeText">Click</button>
    </div>
    
    <div id="app-1">
        {{ name }}
        <button @click="changeText">Click</button>
    </div>
 
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                name : 'koko'
            },
            methods: {
                changeText(){
                    app1.name = 'kossie updated'
                }
 
            }
 
        });
 
        const app1 = new Vue({
            el: '#app-1',
            data: {
                name : 'koko1'
            },
            methods: {
                changeText(){
                    this.name = 'kossie1 updated'
                }
 
            }
 
        });
    </script>
</body>
cs


위의 클릭을 누르면 아래의 메시자가 변경된다. 


+ Recent posts