質問編集履歴

3

Main.jsを追加

2020/04/02 17:22

投稿

Swedon
Swedon

スコア67

test CHANGED
File without changes
test CHANGED
@@ -215,3 +215,183 @@
215
215
 
216
216
 
217
217
  ```
218
+
219
+
220
+
221
+ ```Main
222
+
223
+ import Vue from 'vue'
224
+
225
+ import App from './App.vue'
226
+
227
+ import BootstrapVue from 'bootstrap-vue'
228
+
229
+ import 'bootstrap/dist/css/bootstrap.css'
230
+
231
+ import 'bootstrap-vue/dist/bootstrap-vue.css'
232
+
233
+ import VueRouter from 'vue-router'
234
+
235
+ import MainPage from './components/MainPage.vue'
236
+
237
+ import ProductPage from './components/ProductPage.vue'
238
+
239
+ import Category from './components/Category.vue'
240
+
241
+
242
+
243
+ import axios from "axios";
244
+
245
+ import ShoppingCartPage from './components/ShoppingCartPage.vue'
246
+
247
+ import OrderListing from './components/OrderListing.vue'
248
+
249
+
250
+
251
+
252
+
253
+ Vue.config.productionTip = false
254
+
255
+ Vue.use(BootstrapVue)
256
+
257
+ Vue.use(VueRouter)
258
+
259
+
260
+
261
+ const router = new VueRouter({
262
+
263
+ routes: [{
264
+
265
+ path: '/',
266
+
267
+ component: MainPage
268
+
269
+ },
270
+
271
+
272
+
273
+ {
274
+
275
+ path: '/categories/:categoryAlias',
276
+
277
+ component: Category
278
+
279
+ },
280
+
281
+ {
282
+
283
+ path: '/products/:productId',
284
+
285
+ component: ProductPage
286
+
287
+ },
288
+
289
+ {
290
+
291
+ path: '/cart',
292
+
293
+ component: ShoppingCartPage
294
+
295
+ },
296
+
297
+ {
298
+
299
+ path: '/order',
300
+
301
+ component: OrderListing
302
+
303
+ }
304
+
305
+ ],
306
+
307
+ mode: 'history'
308
+
309
+ });
310
+
311
+
312
+
313
+ axios.defaults.headers.common['Authorization'] = 'Bearer pasuwaado135@gmail.com';
314
+
315
+
316
+
317
+ if (localStorage.cartId) {
318
+
319
+ axios.get("https://euas.person.ee/user/carts" + localStorage.cartId).then(response => {
320
+
321
+ new Vue({
322
+
323
+ render: h => h(App),
324
+
325
+ router: router,
326
+
327
+ data: {
328
+
329
+ cart: response.data,
330
+
331
+ saveCart() {
332
+
333
+ axios.put("https://euas.person.ee/user/carts/" + this.cart.id, this.cart)
334
+
335
+ },
336
+
337
+ reinitCart() {
338
+
339
+ axios.post("https://euas.person.ee/user/carts").then(response => {
340
+
341
+ localStorage.cartId = response.data.id
342
+
343
+ this.cart = response.data;
344
+
345
+ })
346
+
347
+ }
348
+
349
+ }
350
+
351
+ }).$mount('#app')
352
+
353
+ });
354
+
355
+ } else {
356
+
357
+ axios.post("https://euas.person.ee/user/carts").then(response => {
358
+
359
+ new Vue({
360
+
361
+ render: h => h(App),
362
+
363
+ router: router,
364
+
365
+ data: {
366
+
367
+ cart: response.data,
368
+
369
+ saveCart() {
370
+
371
+ axios.put("https://euas.person.ee/user/carts/" + this.cart.id, this.cart)
372
+
373
+ },
374
+
375
+ reinitCart() {
376
+
377
+ axios.post("https://euas.person.ee/user/carts").then(response => {
378
+
379
+ localStorage.cartId = response.data.id
380
+
381
+ this.cart = response.data;
382
+
383
+ })
384
+
385
+ }
386
+
387
+ }
388
+
389
+ }).$mount('#app')
390
+
391
+ });
392
+
393
+ }
394
+
395
+
396
+
397
+ ```

2

試したことの追加

2020/04/02 17:22

投稿

Swedon
Swedon

スコア67

test CHANGED
File without changes
test CHANGED
@@ -12,6 +12,14 @@
12
12
 
13
13
 
14
14
 
15
+ 試したこと
16
+
17
+ ・Safariで表示しているので、ChromeとFirefoxでlocalhostを開きましたが、同じ結果でした
18
+
19
+ ・@clickをもう一つ追加して、更新するメソッドを付け足すとエラーになりました
20
+
21
+
22
+
15
23
  ご存知の方がいれば、教えていただけると幸いです。
16
24
 
17
25
 

1

開発環境の説明に誤りが会ったため

2020/04/02 09:36

投稿

Swedon
Swedon

スコア67

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  開発環境
6
6
 
7
- Mac, Vue.js, Boostrap
7
+ Mac, Vue.js, BoostrapVue
8
8
 
9
9
 
10
10
 
@@ -24,7 +24,7 @@
24
24
 
25
25
  ボタンを押した後↓ 緑色の"Order Now!"ボタンが消え、プロダクトもクリーンになっていますが、これは手動(command + R)で更新した場合です。これをボタンを押すと同時に自動で更新するには、どうしたら良いでしょうか?
26
26
 
27
- ![![現在は手動で更新しています](8f900c3355c006ebbba70ba1737adea1.png)]
27
+ ![![現在は手動で更新しています](8f900c3355c006ebbba70ba1737adea1.png)
28
28
 
29
29
 
30
30