-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvueAlert.js
47 lines (46 loc) · 1.4 KB
/
vueAlert.js
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
const vueAlert = function() {
return {
appendVue() {
const MainComponent = Vue.extend({
template: `
<div>
<h1>Message</h1>
<li v-for="message in listOfMessages"> {{ message }}</li>
<br>
<input v-model="inputMessage">
<button @click="addAnotherMessage">Add another message</button>
<button-counter></button-counter>
</div>`,
data() {
return {
listOfMessages: ["message 1", "message 2", "message 3", "message 4", "message 5"],
inputMessage: ""
}
},
methods: {
addAnotherMessage() {
this.listOfMessages.push(this.inputMessage)
}
}
})
Vue.component("button-counter", {
data: function() {
return {
count: 0
}
},
template: `
<div class="block">
<div class="block__square block__square-pink" onclick="alertPink()"></div>
<div class="block__square block__square-red" onclick="alertRed()"></div>
<div class="block__square block__square-blue" onclick="alertBlue()"></div>
<div class="block__square block__square-green" onclick="alertGreen()"></div>
<div class="block__square block__square-yellow" onclick="alertYellow()"></div>
</div>
`
})
const component = new MainComponent().$mount()
document.body.appendChild(component.$el)
}
}
}()