Skip to content

Commit 158c041

Browse files
author
Shaun Pelling
committed
added lesson 30 code
1 parent f707e86 commit 158c041

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/components/addBlog.vue

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,30 @@
33
<h2>Add a New Blog Post</h2>
44
<form>
55
<label>Blog Title:</label>
6-
<input type="text" v-model="blog.title" required />
6+
<input type="text" v-model.lazy="blog.title" required />
77
<label>Blog Content:</label>
8-
<textarea v-model="blog.content"></textarea>
8+
<textarea v-model.lazy.trim="blog.content"></textarea>
9+
<div id="checkboxes">
10+
<p>Blog Categories:</p>
11+
<label>Ninjas</label>
12+
<input type="checkbox" value="ninjas" v-model="blog.categories" />
13+
<label>Wizards</label>
14+
<input type="checkbox" value="wizards" v-model="blog.categories" />
15+
<label>Mario</label>
16+
<input type="checkbox" value="mario" v-model="blog.categories" />
17+
<label>Cheese</label>
18+
<input type="checkbox" value="cheese" v-model="blog.categories" />
19+
</div>
920
</form>
1021
<div id="preview">
1122
<h3>Preview blog</h3>
1223
<p>Blog title: {{ blog.title }}</p>
1324
<p>Blog content:</p>
1425
<p style="white-space: pre">{{ blog.content }}</p>
26+
<p>Blog Categories:</p>
27+
<ul>
28+
<li v-for="category in blog.categories">{{ category }}</li>
29+
</ul>
1530
</div>
1631
</div>
1732
</template>
@@ -24,7 +39,8 @@ export default {
2439
return {
2540
blog: {
2641
title: '',
27-
content: ''
42+
content: '',
43+
categories: []
2844
}
2945
}
3046
},
@@ -59,4 +75,11 @@ input[type="text"], textarea{
5975
h3{
6076
margin-top: 10px;
6177
}
78+
#checkboxes input{
79+
display: inline-block;
80+
margin-right: 10px;
81+
}
82+
#checkboxes label{
83+
display: inline-block;
84+
}
6285
</style>

0 commit comments

Comments
 (0)