質問編集履歴

3

初心者マーク

2020/03/14 22:00

投稿

tenlife
tenlife

スコア70

test CHANGED
File without changes
test CHANGED
@@ -210,6 +210,42 @@
210
210
 
211
211
  ```
212
212
 
213
+ ```app
214
+
215
+ const router = new VueRouter({
216
+
217
+ routes: [
218
+
219
+ {
220
+
221
+ path: '/follow/:id',
222
+
223
+ name: 'user.follow',
224
+
225
+ component: FollowComponent,
226
+
227
+ props: true
228
+
229
+ }
230
+
231
+ ]
232
+
233
+ })
234
+
235
+
236
+
237
+ ```
238
+
239
+ ```
240
+
241
+ <router-link v-bind:to="{name: 'user.follow'}">
242
+
243
+ <button class="btn btn-primary" type="submit">Follow</button>
244
+
245
+ </router-link>
246
+
247
+ ```
248
+
213
249
  ```エラー
214
250
 
215
251
  エラー

2

初心者マーク

2020/03/14 22:00

投稿

tenlife
tenlife

スコア70

test CHANGED
File without changes
test CHANGED
@@ -132,13 +132,13 @@
132
132
 
133
133
  data() {
134
134
 
135
- return[
135
+ return{
136
-
136
+
137
- currentFollowing = this.following,
137
+ currentFollowing: this.following,
138
-
138
+
139
- sending = false
139
+ sending: false
140
-
140
+
141
- ]
141
+ }
142
142
 
143
143
  },
144
144
 
@@ -216,12 +216,4 @@
216
216
 
217
217
  [Vue warn]: Missing required prop: "id"
218
218
 
219
- [Vue warn]: Error in data(): "ReferenceError: currentFollowing is not defined"
220
-
221
- ReferenceError: currentFollowing is not defined
222
-
223
- [Vue warn]:Property or method "currentFollowing" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property
224
-
225
- [Vue warn]: Property or method "sending" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
226
-
227
- ```
219
+ ```

1

初心者マーク

2020/03/14 21:37

投稿

tenlife
tenlife

スコア70

test CHANGED
File without changes
test CHANGED
@@ -115,3 +115,113 @@
115
115
 
116
116
 
117
117
  よろしくお願いします。
118
+
119
+
120
+
121
+
122
+
123
+ 追記
124
+
125
+ 手探りで書きながらです。(下にエラーあります)
126
+
127
+ ```ここに言語を入力
128
+
129
+ <script>
130
+
131
+ export default {
132
+
133
+ data() {
134
+
135
+ return[
136
+
137
+ currentFollowing = this.following,
138
+
139
+ sending = false
140
+
141
+ ]
142
+
143
+ },
144
+
145
+ props: {
146
+
147
+ id: {
148
+
149
+ type: String,
150
+
151
+ required: true
152
+
153
+ },
154
+
155
+ following: {
156
+
157
+ type: Boolean,
158
+
159
+ default: false
160
+
161
+ }
162
+
163
+ },
164
+
165
+ methods: {
166
+
167
+ async follow() {
168
+
169
+ if(this.sending){
170
+
171
+ return
172
+
173
+ }
174
+
175
+ this.sending = true
176
+
177
+ const data = { id: this.id }
178
+
179
+ await axios.post('/follow-users', data)
180
+
181
+ this.currentFollowing = true
182
+
183
+ this.sending = false
184
+
185
+ },
186
+
187
+ async unfollow() {
188
+
189
+ if(this.sending){
190
+
191
+ return
192
+
193
+ }
194
+
195
+ this.sending = true
196
+
197
+ await axios.delete(`/follow-users/${this.id}`)
198
+
199
+ this.currentFollowing = false
200
+
201
+ this.sending = false
202
+
203
+ }
204
+
205
+ }
206
+
207
+ }
208
+
209
+ </script>
210
+
211
+ ```
212
+
213
+ ```エラー
214
+
215
+ エラー
216
+
217
+ [Vue warn]: Missing required prop: "id"
218
+
219
+ [Vue warn]: Error in data(): "ReferenceError: currentFollowing is not defined"
220
+
221
+ ReferenceError: currentFollowing is not defined
222
+
223
+ [Vue warn]:Property or method "currentFollowing" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property
224
+
225
+ [Vue warn]: Property or method "sending" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
226
+
227
+ ```