質問編集履歴

4

()閉じが多かった

2018/01/14 01:29

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -198,8 +198,6 @@
198
198
 
199
199
  })
200
200
 
201
- })
202
-
203
201
  </script>
204
202
 
205
203
  </body>

3

dd

2018/01/14 01:29

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -218,7 +218,9 @@
218
218
 
219
219
  ###試したこと
220
220
 
221
- lig様が同じようなところで記事を書いておりましたが、
221
+ [lig様が同じようなところで記事](https://liginc.co.jp/223132)を書いておりましたが、
222
+
223
+
222
224
 
223
225
  この実装方法がわからずでした。
224
226
 

2

ff

2018/01/13 17:12

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -88,6 +88,14 @@
88
88
 
89
89
  methods:{
90
90
 
91
+ currentSlugFlg:function(currentData){
92
+
93
+ //return currentData.slug === "/consulting/aaaa/"
94
+
95
+ return currentData.slug === location.pathname;
96
+
97
+ },
98
+
91
99
  isCurrent:function(currentData){
92
100
 
93
101
  //return currentData.slug === "/consulting/aaaa/"
@@ -96,7 +104,7 @@
96
104
 
97
105
  //return false;
98
106
 
99
- }
107
+ }
100
108
 
101
109
  },
102
110
 

1

dd

2018/01/13 17:11

投稿

holic
holic

スコア134

test CHANGED
File without changes
test CHANGED
@@ -18,194 +18,188 @@
18
18
 
19
19
  ###該当のソースコード
20
20
 
21
+
22
+
21
- ```js
23
+ ```html
24
+
22
-
25
+ <!DOCTYPE html>
26
+
27
+ <html lang="ja">
28
+
29
+ <head>
30
+
31
+ <meta charset="UTF-8">
32
+
33
+ <title>Document</title>
34
+
35
+ <link rel="stylesheet" href="/css/style.css">
36
+
37
+ <script src="https://unpkg.com/vue/dist/vue.js"></script>
38
+
39
+ </head>
40
+
41
+ <body>
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ <section>
50
+
51
+ <div class="app">
52
+
53
+ <h1 v-for="val in consulting.concat(contents,cop)" v-if="currentSlugFlg(val)">{{val.name}}</h1>
54
+
55
+ <ul>
56
+
57
+ <li v-for="val in consulting" v-bind:class="{ active:isCurrent(val) }"><a v-bind:href="val.slug">{{ val.name }}</a></li>
58
+
59
+ </ul>
60
+
61
+ <hr>
62
+
63
+ <ul>
64
+
65
+ <li v-for="val in contents" v-bind:class="{ active: isCurrent(val) }"><a v-bind:href="val.slug">{{ val.name }}</a></li>
66
+
67
+ </ul>
68
+
69
+ <hr>
70
+
71
+ <ul>
72
+
73
+ <li v-for="val in cop" v-bind:class="{ active: isCurrent(val) }"><a v-bind:href="val.slug">{{ val.name }}</a></li>
74
+
75
+ </ul>
76
+
77
+ </div>
78
+
79
+ </section>
80
+
81
+
82
+
83
+ <script>
84
+
85
+ new Vue({
86
+
23
- $('#point');
87
+ el: '.app',
88
+
89
+ methods:{
90
+
91
+ isCurrent:function(currentData){
92
+
93
+ //return currentData.slug === "/consulting/aaaa/"
94
+
95
+ return currentData.slug === location.pathname;
96
+
97
+ //return false;
98
+
99
+ }
100
+
101
+ },
102
+
103
+ data: {
104
+
105
+ consulting:[
106
+
107
+ {
108
+
109
+ 'slug':'/consulting/aaaa/',
110
+
111
+ 'name':'狭い土地利用'
112
+
113
+ },
114
+
115
+ {
116
+
117
+ 'slug':'/consulting/bbbb/',
118
+
119
+ 'name':'丁度よいい土地利用'
120
+
121
+ },
122
+
123
+ {
124
+
125
+ 'slug':'/consulting/ccccc/',
126
+
127
+ 'name':'広いい土地利用'
128
+
129
+ }
130
+
131
+ ],
132
+
133
+ contents:[
134
+
135
+ {
136
+
137
+ 'slug':'/contents/',
138
+
139
+ 'name':'コンテンツについて'
140
+
141
+ },
142
+
143
+ {
144
+
145
+ 'slug':'/contents/mmmmm/',
146
+
147
+ 'name':'点々'
148
+
149
+ },
150
+
151
+ {
152
+
153
+ 'slug':'/contents/llll/',
154
+
155
+ 'name':'増やしていきましょう'
156
+
157
+ }
158
+
159
+ ],
160
+
161
+ cop:[
162
+
163
+ {
164
+
165
+ 'slug':'/cop/design/',
166
+
167
+ 'name':'デザイン'
168
+
169
+ },
170
+
171
+ {
172
+
173
+ 'slug':'/cop/good/',
174
+
175
+ 'name':'商品'
176
+
177
+ },
178
+
179
+ {
180
+
181
+ 'slug':'/cop/',
182
+
183
+ 'name':'コップ'
184
+
185
+ }
186
+
187
+ ]
188
+
189
+ }
190
+
191
+ })
192
+
193
+ })
194
+
195
+ </script>
196
+
197
+ </body>
198
+
199
+ </html>
24
200
 
25
201
  ```
26
202
 
27
- 上記のjQueryをjavascriptに記述しようとしたら
28
-
29
- ```html
30
-
31
- <!DOCTYPE html>
32
-
33
- <html lang="ja">
34
-
35
- <head>
36
-
37
- <meta charset="UTF-8">
38
-
39
- <title>Document</title>
40
-
41
- <link rel="stylesheet" href="/css/style.css">
42
-
43
- <script src="https://unpkg.com/vue/dist/vue.js"></script>
44
-
45
- </head>
46
-
47
- <body>
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
- <section>
56
-
57
- <div class="app">
58
-
59
- <h1 v-for="val in consulting.concat(contents,cop)" v-if="currentSlugFlg(val)">{{val.name}}</h1>
60
-
61
- <ul>
62
-
63
- <li v-for="val in consulting" v-bind:class="{ active:isCurrent(val) }"><a v-bind:href="val.slug">{{ val.name }}</a></li>
64
-
65
- </ul>
66
-
67
- <hr>
68
-
69
- <ul>
70
-
71
- <li v-for="val in contents" v-bind:class="{ active: isCurrent(val) }"><a v-bind:href="val.slug">{{ val.name }}</a></li>
72
-
73
- </ul>
74
-
75
- <hr>
76
-
77
- <ul>
78
-
79
- <li v-for="val in cop" v-bind:class="{ active: isCurrent(val) }"><a v-bind:href="val.slug">{{ val.name }}</a></li>
80
-
81
- </ul>
82
-
83
- </div>
84
-
85
- </section>
86
-
87
-
88
-
89
- <script>
90
-
91
- new Vue({
92
-
93
- el: '.app',
94
-
95
- methods:{
96
-
97
- isCurrent:function(currentData){
98
-
99
- //return currentData.slug === "/consulting/aaaa/"
100
-
101
- return currentData.slug === location.pathname;
102
-
103
- //return false;
104
-
105
- }
106
-
107
- },
108
-
109
- data: {
110
-
111
- consulting:[
112
-
113
- {
114
-
115
- 'slug':'/consulting/aaaa/',
116
-
117
- 'name':'狭い土地利用'
118
-
119
- },
120
-
121
- {
122
-
123
- 'slug':'/consulting/bbbb/',
124
-
125
- 'name':'丁度よいい土地利用'
126
-
127
- },
128
-
129
- {
130
-
131
- 'slug':'/consulting/ccccc/',
132
-
133
- 'name':'広いい土地利用'
134
-
135
- }
136
-
137
- ],
138
-
139
- contents:[
140
-
141
- {
142
-
143
- 'slug':'/contents/',
144
-
145
- 'name':'コンテンツについて'
146
-
147
- },
148
-
149
- {
150
-
151
- 'slug':'/contents/mmmmm/',
152
-
153
- 'name':'点々'
154
-
155
- },
156
-
157
- {
158
-
159
- 'slug':'/contents/llll/',
160
-
161
- 'name':'増やしていきましょう'
162
-
163
- }
164
-
165
- ],
166
-
167
- cop:[
168
-
169
- {
170
-
171
- 'slug':'/cop/design/',
172
-
173
- 'name':'デザイン'
174
-
175
- },
176
-
177
- {
178
-
179
- 'slug':'/cop/good/',
180
-
181
- 'name':'商品'
182
-
183
- },
184
-
185
- {
186
-
187
- 'slug':'/cop/',
188
-
189
- 'name':'コップ'
190
-
191
- }
192
-
193
- ]
194
-
195
- }
196
-
197
- })
198
-
199
- })
200
-
201
- </script>
202
-
203
- </body>
204
-
205
- </html>
206
-
207
- ```
208
-
209
203
 
210
204
 
211
205