-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
93 lines (91 loc) · 2.05 KB
/
script.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const app = Vue.createApp({
data() {
return {
selected: "",
categories: ["science", "math", "poetry", "history"],
posts: [
{
author: "@vFitzgerald",
title: "Quod Ducimus Omnis",
label: "science",
},
{
author: "@mPalmer",
title: "Vero Eius Laboriosam Ex Repudiandae",
label: "math",
},
{
author: "@mDean",
title: "Magnam Odit",
label: "science",
},
{
author: "@tCole",
title: "Velit Mollitia Voluptates Assumenda",
label: "science",
},
{
author: "@jCooper",
title: "Eum Commodi Cupiditate",
label: "poetry",
},
{
author: "@lLamb",
title: "Amet",
label: "history",
},
{
author: "@fMartin",
title: "Voluptatem Fuga Cum Asperiores Error",
label: "science",
},
{
author: "@eHayes",
title: "Ipsa Consectetur Rerum Repellat Quia",
label: "math",
},
{
author: "@cCollier",
title: "Dolor Nihil Delectus",
label: "science",
},
{
author: "@cBenson",
title: "Labore Ipsum Ad Pariatur",
label: "poetry",
},
],
newTitle: "",
newAuthor: "",
newLabel: "",
};
},
methods: {
addPost() {
let addedPost = {
title: this.newTitle,
author: this.newAuthor,
label: this.newLabel,
};
if (
this.newTitle === "" ||
this.newAuthor === "" ||
this.newLabel === ""
) {
addedPost = false;
} else {
this.posts.push(addedPost);
this.newTitle = "";
this.newAuthor = "";
this.newLabel = "";
}
},
},
computed: {
filteredByLabel() {
let filter = new RegExp(this.selected, "i");
return this.posts.filter((el) => el.label.match(filter));
},
},
});
app.mount("#app");