回答編集履歴
2
調整版
test
CHANGED
@@ -157,3 +157,145 @@
|
|
157
157
|
</script>
|
158
158
|
|
159
159
|
```
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# 調整版
|
164
|
+
|
165
|
+
```javascript
|
166
|
+
|
167
|
+
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
168
|
+
|
169
|
+
<div id="dynamic-component-demo">
|
170
|
+
|
171
|
+
<div v-if="posts.filter(x=>x.category=='メンズ').length>0">
|
172
|
+
|
173
|
+
<div class="posts-tab">
|
174
|
+
|
175
|
+
<ul class="posts-sidebar">
|
176
|
+
|
177
|
+
<li v-for="(post, index) in posts.filter(x=>x.category=='メンズ')" v-bind:key="post.id" v-on:click="selectedNumber = post.id-1">
|
178
|
+
|
179
|
+
{{ post.title }}
|
180
|
+
|
181
|
+
</li>
|
182
|
+
|
183
|
+
</ul>
|
184
|
+
|
185
|
+
<div class="selected-post-container">
|
186
|
+
|
187
|
+
<div class="selected-post">
|
188
|
+
|
189
|
+
<h3>{{ selectedPost.title }}</h3>
|
190
|
+
|
191
|
+
<div v-html="selectedPost.content"></div>
|
192
|
+
|
193
|
+
</div>
|
194
|
+
|
195
|
+
</div>
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
</div>
|
200
|
+
|
201
|
+
<div v-if="posts.filter(x=>x.category=='レディース').length>0">
|
202
|
+
|
203
|
+
<div class="posts-tab">
|
204
|
+
|
205
|
+
<ul class="posts-sidebar">
|
206
|
+
|
207
|
+
<li v-for="(post, index) in posts.filter(x=>x.category=='レディース')" v-bind:key="post.id" v-on:click="selectedNumber = post.id-1">
|
208
|
+
|
209
|
+
{{ post.title }}
|
210
|
+
|
211
|
+
</li>
|
212
|
+
|
213
|
+
</ul>
|
214
|
+
|
215
|
+
<div class="selected-post-container">
|
216
|
+
|
217
|
+
<div class="selected-post">
|
218
|
+
|
219
|
+
<h3>{{ selectedPost.title }}</h3>
|
220
|
+
|
221
|
+
<div v-html="selectedPost.content"></div>
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
</div>
|
226
|
+
|
227
|
+
</div>
|
228
|
+
|
229
|
+
</div>
|
230
|
+
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<script>
|
234
|
+
|
235
|
+
new Vue({
|
236
|
+
|
237
|
+
el: '#dynamic-component-demo',
|
238
|
+
|
239
|
+
data: {
|
240
|
+
|
241
|
+
posts: [{
|
242
|
+
|
243
|
+
id: 1,
|
244
|
+
|
245
|
+
title: 'タイトル1',
|
246
|
+
|
247
|
+
content: '<p>本文1</p>',
|
248
|
+
|
249
|
+
category: 'メンズ'
|
250
|
+
|
251
|
+
}, {
|
252
|
+
|
253
|
+
id: 2,
|
254
|
+
|
255
|
+
title: 'タイトル2',
|
256
|
+
|
257
|
+
content: '<p>本文2</p>',
|
258
|
+
|
259
|
+
category: 'メンズ'
|
260
|
+
|
261
|
+
}, {
|
262
|
+
|
263
|
+
id: 3,
|
264
|
+
|
265
|
+
title: 'タイトル3',
|
266
|
+
|
267
|
+
content: '<p>本文3</p>',
|
268
|
+
|
269
|
+
category: 'レディース'
|
270
|
+
|
271
|
+
}, {
|
272
|
+
|
273
|
+
id: 4,
|
274
|
+
|
275
|
+
title: 'タイトル4',
|
276
|
+
|
277
|
+
content: '<p>本文4</p>',
|
278
|
+
|
279
|
+
category: 'メンズ'
|
280
|
+
|
281
|
+
}],
|
282
|
+
|
283
|
+
selectedNumber: 0
|
284
|
+
|
285
|
+
},
|
286
|
+
|
287
|
+
computed: {
|
288
|
+
|
289
|
+
selectedPost() {
|
290
|
+
|
291
|
+
return this.posts[this.selectedNumber]
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
});
|
298
|
+
|
299
|
+
</script>
|
300
|
+
|
301
|
+
```
|
1
ちょうせい
test
CHANGED
@@ -9,3 +9,151 @@
|
|
9
9
|
<div v-if="posts.filter(x=>x.category=='メンズ').length>0">
|
10
10
|
|
11
11
|
```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
# sample
|
16
|
+
|
17
|
+
メンズにタイトル1,2,4、レディースに3を表示するのはイメージがつくのですが
|
18
|
+
|
19
|
+
その他の項目はどうなればいいのでしょうか?
|
20
|
+
|
21
|
+
結果をHTMLに書き起こしてもらい、仕様説明をしてもらえると書きようもあるかと
|
22
|
+
|
23
|
+
```javascript
|
24
|
+
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
26
|
+
|
27
|
+
<div id="dynamic-component-demo">
|
28
|
+
|
29
|
+
<div v-if="posts.filter(x=>x.category=='メンズ').length>0">
|
30
|
+
|
31
|
+
<div class="posts-tab">
|
32
|
+
|
33
|
+
<ul class="posts-sidebar">
|
34
|
+
|
35
|
+
<li v-for="(post, index) in posts.filter(x=>x.category=='メンズ')" v-bind:key="post.id" v-on:click="selectedNumber = index">
|
36
|
+
|
37
|
+
{{ post.title }}
|
38
|
+
|
39
|
+
</li>
|
40
|
+
|
41
|
+
</ul>
|
42
|
+
|
43
|
+
<div class="selected-post-container">
|
44
|
+
|
45
|
+
<div class="selected-post">
|
46
|
+
|
47
|
+
<h3>{{ selectedPost.title }}</h3>
|
48
|
+
|
49
|
+
<div v-html="selectedPost.content"></div>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div v-if="posts.filter(x=>x.category=='レディース').length>0">
|
60
|
+
|
61
|
+
<div class="posts-tab">
|
62
|
+
|
63
|
+
<ul class="posts-sidebar">
|
64
|
+
|
65
|
+
<li v-for="(post, index) in posts.filter(x=>x.category=='レディース')" v-bind:key="post.id" v-on:click="selectedNumber = index">
|
66
|
+
|
67
|
+
{{ post.title }}
|
68
|
+
|
69
|
+
</li>
|
70
|
+
|
71
|
+
</ul>
|
72
|
+
|
73
|
+
<div class="selected-post-container">
|
74
|
+
|
75
|
+
<div class="selected-post">
|
76
|
+
|
77
|
+
<h3>{{ selectedPost.title }}</h3>
|
78
|
+
|
79
|
+
<div v-html="selectedPost.content"></div>
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<script>
|
92
|
+
|
93
|
+
new Vue({
|
94
|
+
|
95
|
+
el: '#dynamic-component-demo',
|
96
|
+
|
97
|
+
data: {
|
98
|
+
|
99
|
+
posts: [{
|
100
|
+
|
101
|
+
id: 1,
|
102
|
+
|
103
|
+
title: 'タイトル1',
|
104
|
+
|
105
|
+
content: '<p>本文1</p>',
|
106
|
+
|
107
|
+
category: 'メンズ'
|
108
|
+
|
109
|
+
}, {
|
110
|
+
|
111
|
+
id: 2,
|
112
|
+
|
113
|
+
title: 'タイトル2',
|
114
|
+
|
115
|
+
content: '<p>本文2</p>',
|
116
|
+
|
117
|
+
category: 'メンズ'
|
118
|
+
|
119
|
+
}, {
|
120
|
+
|
121
|
+
id: 3,
|
122
|
+
|
123
|
+
title: 'タイトル3',
|
124
|
+
|
125
|
+
content: '<p>本文3</p>',
|
126
|
+
|
127
|
+
category: 'レディース'
|
128
|
+
|
129
|
+
}, {
|
130
|
+
|
131
|
+
id: 4,
|
132
|
+
|
133
|
+
title: 'タイトル4',
|
134
|
+
|
135
|
+
content: '<p>本文4</p>',
|
136
|
+
|
137
|
+
category: 'メンズ'
|
138
|
+
|
139
|
+
}],
|
140
|
+
|
141
|
+
selectedNumber: 0
|
142
|
+
|
143
|
+
},
|
144
|
+
|
145
|
+
computed: {
|
146
|
+
|
147
|
+
selectedPost() {
|
148
|
+
|
149
|
+
return this.posts[this.selectedNumber]
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
});
|
156
|
+
|
157
|
+
</script>
|
158
|
+
|
159
|
+
```
|