-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (60 loc) · 1.65 KB
/
index.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vue JS Playground</title>
</head>
<body>
<div id="mon-app1">
<mon-premier-composant></mon-premier-composant>
<mon-premier-composant></mon-premier-composant>
<mon-premier-composant></mon-premier-composant>
<mon-premier-composant></mon-premier-composant>
</div>
<div id="mon-app2">
<h1>{{ txt }}</h1>
<button v-on:click="func1">CHANGEMENT</button>
</div>
<!-- Installation de VueJS 2 -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script type="text/javascript">
Vue.component("mon-premier-composant", {
template: ` <p>Mon premier composant {{ nom }}
<button v-on:click="changementNom">Changement</button>
</p>`,
data: function() {
return {
nom: "John Doe",
}
},
methods: {
changementNom: function() {
this.nom = "Jack Doe";
}
}
})
// Création d'une instance
const ins1 = new Vue({
el: "#mon-app1",
data: {
txt: "Hello APP 1"
},
});
// Création d'une instance
const ins2 = new Vue({
el: "#mon-app2",
data: {
txt: "Hello APP 2"
},
methods: {
func1: function() {
ins1.txt = "Je t'ai changée";
}
}
});
console.log(ins1.txt);
</script>
</body>
</html>