-
Notifications
You must be signed in to change notification settings - Fork 975
/
Copy pathmain.js
63 lines (62 loc) · 2 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import Vue from 'vue';
import './style.scss';
import genres from './util/genres'
new Vue({
el: '#app',
components: {
'movie-list': {
template: `<div id="movie-list">
<div class="movie" v-for="movie in movies">{{movie.title}}</div>
</div>`,
data() {
return {
movies: [
{ title: 'Pulp Fiction' },
{ title: 'Home Alone' },
{ title: 'Austin Powers' },
]
}
},
},
'movie-filter': {
data() {
return {
genres
}
},
template: `<div id="movie-filter">
<h2>Filter results</h2>
<div class="filter-group">
<check-filter v-for="genre in genres" :title="genre" v-on:check-filter="checkFilter"></check-filter>
</div>
</div>`,
methods: {
checkFilter() {
console.log('CheckFilter')
}
},
components: {
'check-filter': {
data() {
return {
checked: false
}
},
props: [
'title'
],
template: `<div :class="{'check-filter': true, active: checked}" @click="checkFilter">
<span class="checkbox"></span>
<span class="check-filter-title">{{title}}</span>
</div>`,
methods: {
checkFilter() {
this.checked = !this.checked
this.$emit('check-filter');
}
}
}
}
}
},
})