Skip to content

๐Ÿ†Ž์—์ด๋ธ”๋ฆฌ ์ต์Šคํ„ด์‹ญ

Notifications You must be signed in to change notification settings

lee-ji-hong/frontend-mission

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

79 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ†Žfrontend-mission

ํ”„๋กœ์ ํŠธ ์†Œ๊ฐœ

์—์ด๋ธ”๋ฆฌ์™€ ๋ฉ‹์Ÿ์ด ์‚ฌ์ž๋“ค์ฒ˜๋Ÿผ์—์„œ ์ง„ํ–‰ํ•˜๋Š” CleanCode TDD,Vue.js ๊ธฐ๋ฐ˜์œผ๋กœ ๊ต์œกํ˜• ์ต์Šคํ„ด์‹ญ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ”„๋กœ์ ํŠธ ์ž…๋‹ˆ๋‹ค. FE Externship 1๊ธฐ๋กœ ์ฐธ๊ฐ€ํ•˜์—ฌ ์ฃผ์ฐจ๋ณ„ ๋ฏธ์…˜์„ ์ง„ํ–‰ํ•˜์—ฌ ์—์ด๋ธ”๋ฆฌ ๋ชจ๋ฐ”์ผ ์›น ์‚ฌ์ดํŠธ๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ด ํ”„๋กœ์ ํŠธ๋ฅผ ํ†ตํ•ด ๋ฐฐ์šด์  & ๋ฌธ์ œ ํ•ด๊ฒฐ

  • ์ฒ˜์Œ์œผ๋กœ vue ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ jest ์‚ฌ์šฉ์„ ํ•ด๋ดค์Šต๋‹ˆ๋‹ค.
  • ๊ธฐ๋ณธ์ ์ธ vue ๋ผ์ดํ”„์‚ฌ์ดํด ํ›…์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ฃผ์ฐจ๋ณ„ ๊ตฌํ˜„ ๋‚ด์šฉ

1์ฃผ์ฐจ - Boilerplate์ฝ”๋“œ์—์„œ ์ผ๋ถ€๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ๊ฐœ๋ฐœ ํŽ˜์ด์ง€์— ๋„์šฐ๊ธฐ & Vue.js ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์„ธํŒ…ํ•˜๊ธฐ

Hnet-image

์ ‘๊ทผ ๋ฐฉ๋ฒ•

  • ๋ฏธ์…˜ ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์–ด๋–ค ์ƒ๊ฐ๋“ค์„ ํ–ˆ๋Š”์ง€ ์ •๋ฆฌํ•ด๋ณด์„ธ์š”.
  • ์ฝ”๋“œ์— ๊ฐ€๋…์„ฑ๊ณผ ์ดํ•ด๋„๋ฅผ ๋†’์ด๊ธฐ ์œ„ํ•ด commit๋ฉ”์„ธ์ง€ ๊ธฐ๋ณธ ๊ทœ์น™์— ๋”ฐ๋ผ ์ ์šฉํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • TDD ์ž‘์„ฑ ์›์น™์— ์˜ํ•ด ์ตœ์†Œํ•œ์˜ ๊ธฐ๋Šฅ๋“ค์„ ๊ตฌํ˜„ํ•œ ํ›„ ํ…Œ์ŠคํŠธ ํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋Š๋‚€์ 

  • vue๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐœ๋ฐœํ•˜๋Š” ๊ฒƒ์ด ์ฒ˜์Œ์ด๋ผ ๊ณผ์ œ์ง„ํ–‰์„ ํ•˜๋ฉด์„œ ์ƒ๊ธฐ๋Š” ์˜ค๋ฅ˜๋“ค์„ ์ฒ˜์Œ ์ ‘ํ•˜๋Š” ๊ฒƒ๋“ค์ด์—ˆ์Šต๋‹ˆ๋‹ค. ๊ตฌ๊ธ€๋งํ•˜๋ฉด์„œ ์˜ค๋ฅ˜ ์ฝ”๋“œ ์ˆ˜์ •ํ•˜๊ณ  ์ „์ฒด ๊ธฐ๋Šฅ๋“ค ๋˜ํ•œ ๊ณต๋ถ€ํ•˜๋ฉด์„œ ๋™์‹œ์— ๊ณผ์ œ ์ˆ˜ํ–‰์„ ํ•ด๋‚˜๊ฐ€์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ณผ์ •์—์„œ ์‹œ๊ฐ„ ๋ถ„๋ฐฐ๋ฅผ ์ž˜ ๋ชปํ•œ ์ ์ด ์•„์‰ฌ์› ์ง€๋งŒ 1์ฃผ์ฐจ ๊ณผ์ œ๋ฅผ ํ†ตํ•ด vue์—๋Œ€ํ•ด ์–ด๋Š์ •๋„ ์ˆ™์ง€๋ฅผ ํ•œ๊ฒƒ ๊ฐ™์•„ ์žฌ๋ฏธ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค
  • ๋˜ํ•œ TDD๋ฅผ ํ†ตํ•ด ์ฝ”๋”ฉํ•˜๋Š” ๊ฒƒ๋„ ์ฒ˜์Œ ์‹œ๋„ํ•ด๋ณด๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ,๊ทธ ๊ณผ์ •์—์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ vue ๊ณต์‹๋ฌธ์„œ๋‚˜ ์œ ํŠœ๋ธŒ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ์‹คํ–‰ํ–ˆ๋Š”๋ฐ, ์กฐ๊ธˆ๋” ํด๋ฆฐํ•œ ์ฝ”๋“œ๋ฅผ ์งœ์ง€ ๋ชปํ•œ๊ฑฐ ๊ฐ™์•„ ์•„์‰ฌ์› ์Šต๋‹ˆ๋‹ค.
  • ํšŒ์ „๋ฌธ์ž์—ด๊ณผ alert์ฐฝ ๊ตฌํ˜„์„ ๊ฐ™์€ component์—์„œ ์ง„ํ–‰ํ•˜๊ณ  ํ…Œ์ŠคํŠธ ํ–ˆ๋˜ ์ ์ด ์ข€ ์•„์‰ฝ๊ฒŒ ๋Š๊ปด์ง‘๋‹ˆ๋‹ค.

code presentation

https://drive.google.com/file/d/1fCSrUfxCfLk_kyU5xTElBlnDmdUIrPZK/view

2์ฃผ์ฐจ - Component ์„ค๊ณ„(์—์ด๋ธ”๋ฆฌ ์ƒํ’ˆ ์ƒํŽ˜ ํŽ˜์ด์ง€ 1์ฐจ)

Hnet-image (1)

์ ‘๊ทผ ๋ฐฉ๋ฒ•

  • ํ•˜๋‚˜์˜ ํŒ€์ด ๋งŒ๋“ค์–ด ์กŒ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์„๋•Œ ์†Œํ†ต์˜ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ธฐ์ง€ ์•Š๋„๋ก ์š”๊ตฌ์‚ฌํ•ญ์„ ์„ธ๋ถ€์ ์œผ๋กœ ๋‚˜๋ˆ„์–ด ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•˜๋ ค ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ์ฝ”๋“œ์˜ ๋ถˆํ•„์š”ํ•œ ๋ฐ˜๋ณต์„ ์ค„์—ฌ ์œ ์ง€๋ณด์ˆ˜ํ•  ์‹œ ์ฝ”๋“œ๋ฅผ ์ฝ๋Š”๋ฐ ์–ด๋ ค์›€์ด ์—†๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ํŽ˜์ด์ง€ ์ด๋™ํ•  ์‹œ ๋™์  ๋ผ์šฐํŒ… ๋งค์นญ์„ ์ด์šฉํ•˜์—ฌ ๋™์ ์ธ ์‹œ๊ฐ์  ์š”๊ตฌ์‚ฌํ•ญ์„ ๋„์ถœํ•˜๋Š” ๊ฒƒ์— ์‹ ๊ฒฝ์ผ์Šต๋‹ˆ๋‹ค.
  • ์ƒํ’ˆ๋ฆฌ์ŠคํŠธ์—… ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ ํ•œ ํ›„ ์ƒ์„ธํŽ˜์ด์ง€๋กœ ๋กœ๋”ฉ์ด ๋œ๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋˜์–ด์„œ ์ƒ์„ธํŽ˜์ด์ง€ ๊ตฌํ˜„ํ•˜๊ธฐ ์ „ ์ƒํ’ˆ ๋ฆฌ์ŠคํŠธํŽ˜์ด์ง€๋ฅผ ๋จผ์ € ๋งŒ๋“  ํ›„ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์—‘์…€

๋Š๋‚€์ 

  • vue ํ”„๋ ˆ์ž„ ์›Œํฌ ๋‚ด์—์„œ ๋™์  ๋ผ์šฐํŒ… ๋งค์นญ์„ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์–ด๋–ค์‹์œผ๋กœ ์ด๋ฃจ์–ด์ง€๋Š”์ง€ ์ž˜ ์ดํ•ด๊ฐ€ ๊ฐ€์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ์œ ํŠœ๋ธŒ๋‚˜ ๊ณต์‹๋ฌธ์„œ๋ฅผ ๋ณด๋ฉฐ ๋”ฐ๋ผํ•˜๋ฉฐ ์ฃผ๋จน๊ตฌ๊ตฌ์‹์œผ๋กœ ๊ตฌํ˜„ํ•ด๋ณด์•˜๋Š”๋ฐ ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ๋ฒ•์ธ์ง€๋Š” ํ™•์‹ ์ด ๋“ค์ง€ ์•Š์•„ ์กฐ๊ธˆ ๋” ์•Œ์•„๋ณผ ํ•„์š”๊ฐ€ ์žˆ์„๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

code presentation

https://drive.google.com/file/d/1cpzVyuyIAHUU_4rpSpKvoNfXvcFiS7ZU/view

3์ฃผ์ฐจ - Component ์„ค๊ณ„ ์‹ฌํ™”(์—์ด๋ธ”๋ฆฌ ์ƒํ’ˆ ๋ชฉ๋ก ํŽ˜์ด์ง€)

Hnet com-image (1)

์ ‘๊ทผ ๋ฐฉ๋ฒ•

  • ์›๋ž˜๋Š” ๊ธฐํš์ž๊ฐ€ ํ•ด์•ผํ•˜๋Š” ์ผ์ด๋ผ๊ณ  ์•Œ๊ณ  ์žˆ์ง€๋งŒ ์ดˆ๊ธฐ ํ”„๋กœ์ ํŠธ๋ผ๋Š” ๊ฐ€์ •ํ•˜์— ์ง์ ‘ ํ”„๋ก ํŠธ์—”๋“œ์—์„œ ํ”„๋กœํ† ํƒ€์ž…์„ ์ œ์ž‘ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

  • ์š”๊ตฌ์‚ฌํ•ญ ๋ช…์„ธ๋ฅผ ์ด์šฉํ•ด ๊ฐ„๋‹จํ•˜๊ฒŒ ์ƒ์„ธ์ •๋ณด ํŽ˜์ด์ง€์— ๋Œ€ํ•œ ๊ธฐํš์„œ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค. 20220124_134852

  • ํŽ˜์ด์ง€ ์ œ์ž‘ ์ „ ์š”๊ตฌ์‚ฌํ•ญ ๋ช…์„ธ๋ฅผ ๋ชฉ๋ก๋ณ„๋กœ ์„ธ๋ถ„ํ™”ํ•ด ๊ธฐ๋Šฅ๋ณ„ ๊ตฌํ˜„์ด ์ œ๋Œ€๋กœ ๋˜๋„๋ก ์ž‘์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค.

image

  • ์ฝ”๋“œ์˜ ์žฌ์‚ฌ์šฉ์„ฑ์„ ๋†’์ด๊ณ  ์œ ์ง€๋ณด์ˆ˜์„ฑ๊ณผ ์œ ์—ฐ์„ฑ์„ ๊ณ ๋ คํ•˜์—ฌ ๋ถ€๋ชจ์ปดํฌ๋„ŒํŠธ์ธ ItemLIst ์•„๋ž˜์— ์ž์‹ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๊ธฐ๋Šฅ๋ณ„๋กœ ๊ฐ๊ฐ ๋‚˜๋ˆ„๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ์žฌ์‚ฌ์šฉ์„ฑ์„ ์œ„ํ•ด ๊ตฌํ˜„ํ•œ ์ปดํฌ๋„ŒํŠธ๋“ค์„ ๋ถ€๋ชจ์ปดํฌ๋„ŒํŠธ์™€ ๋ผ์šฐํŒ…ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ํ—ค๋” ์ปดํฌ๋„ŒํŠธ๋ฅผ ๊ตฌํ˜„ํ• ๋•Œ ํ—ค๋”๊ฐ€ ๋ณด์ด๊ณ  ์‚ฌ๋ผ์ง€๋Š” ๋™์ž‘๋“ค์„ Lifrcycle Hook์„ ์ด์šฉํ•ด ํ—ค๋” ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๊ฐ€ ๋™์ž‘ํ•  ๋•Œ mounted๋ฅผ ์ฃผ์–ด ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์— ์ „๋‹ฌ๋˜๊ฒŒ ํ•˜๊ณ , ํ•ด๋‹น component๊ฐ€ ๋™์ž‘์ด ํ•ด์ฒด๋˜๊ธฐ ์ง์ „์— beforeunmountedํ›…์ด ํ˜ธ์ถœ๋˜๊ฒŒ ํ•˜์—ฌ method ์†์„ฑ์— ์ ‘๊ทผํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ์ปดํฌ๋„ŒํŠธ๋“ค์„ ์„ธ๋ถ„ํ™”ํ•ด ์ž‘์—…ํ•œ ๋งŒํผ ํ…Œ์ŠคํŠธํŒŒ์ผ์„ ๊ฐ๊ฐ ์ƒ์„ฑํ•ด ํ…Œ์ŠคํŠธ ํ•ด์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.

๋Š๋‚€์ 

-vue.js์˜ ํŠน์„ฑ์ƒ ๊ฐœ๋ฐœ ๊ทœ๋ชจ๊ฐ€ ์ปค์งˆ์ˆ˜๋ก ์ฝ”๋“œ๊ฐ€ ๋ฐฉ๋Œ€ํ•˜๊ณ  ๋ณต์žกํ•ด์ง€๋Š” ๋‹จ์ ์ด ์žˆ๋Š”๋ฐ ์ด๊ฒƒ์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ composition API์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์œ ์ง€๋ณด์ˆ˜์„ฑ๊ณผ ์œ ์—ฐ์„ฑ์„ ์กฐ๊ธˆ ๋” ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•œ ๋ถ€๋ถ„์ด ์•„์‰ฝ์Šต๋‹ˆ๋‹ค.

code presentation

https://drive.google.com/file/d/1jNcyPSXgkje_8Y6iCNw8GxebxpGEoSgb/view

4์ฃผ์ฐจ - ํŽ˜์ด์ง€ ๋ผ์šฐํŒ… ๋ฐ API ์—ฐ๋™

Hnet-image

์ ‘๊ทผ ๋ฐฉ๋ฒ•

  • vue-router๋ฅผ ๋™์  ๋ผ์šฐํŒ… ๋งค์นญ์„ ํ†ตํ•˜์—ฌ Single Page Application (์ดํ•˜ SPA)์—์„œ ์„œ๋กœ ๋‹ค๋ฅธ ํ™”๋ฉด์„ ์ƒํ˜ธ์ž‘์šฉ์— ๋”ฐ๋ผ ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

  • APIํ˜ธ์ถœ์„ ํ•  ๋•Œ ๋ฏธ์…˜ ์š”๊ตฌ์‚ฌํ•ญ์ธ Repository pattern ํ†ตํ•œ ์—ฐ๋™์€ ์ฒ˜์Œ์ด๋ผ ํ•ด๋‹น ๋ถ€๋ถ„์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ณ  ์ •๋ฆฌ ํ›„ ๊ฐœ๋ฐœ์„์‹œ์ž‘ํ–ˆ์Šต๋‹ˆ๋‹ค.

  1. Repository Pattern์ด๋ž€?
  2. Vue.js์—์„œ Repository pattern์ ์šฉ๋ฐฉ๋ฒ•
  • Repository pattern์„ ํ†ตํ•˜์—ฌ API ์—ฐ๋™์„ ์‚ฌ์šฉํ–ˆ๊ณ  Axios HTTP client๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๋ผ์šฐํŒ…์„ ์‹คํ–‰ํ•  ๋•Œ "Using a Real Router " ๋ฐฉ๋ฒ•์„ ์ ์šฉํ•˜์—ฌ ํ…Œ์ŠคํŠธ ํ•˜๋„๋ก ๋…ธ๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค.

๋Š๋‚€์ 

  • Using a Real Router " ๋ฐฉ๋ฒ•์„ ์ ์šฉํ•˜์—ฌ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•ด๋ณด๊ธด ํ–ˆ์ง€๋งŒ ํ™•์‹คํžˆ ์ฒด๋“์€ ์•ˆ๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์—ฐ์Šต์ด ๋งŽ์ด ํ•„์š”ํ•จ์„ ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค.
  • ์ถ”๊ฐ€ ๋ฏธ์…˜์ธ ๊ตฌํ˜„๋˜์ง€ ์•Š์€ ๋‹ค๋ฅธ ํŽ˜์ด์ง€๋“ค์„ ๊ฐœ๋ฐœํ•˜๊ณ  API์—ฐ๋™๊นŒ์ง€ ํ•˜์ง€ ๋ชปํ•ด ์•„์‰ฝ์Šต๋‹ˆ๋‹ค.

code presentation

https://drive.google.com/file/d/1FQJmWz26WrCZ0Sw6up6JF_9fMApTJulY/view

5์ฃผ์ฐจ - ์ƒํƒœ๊ด€๋ฆฌ, ์ƒํ’ˆ ์ฃผ๋ฌธ ํ”„๋กœ์„ธ์Šค ๊ตฌํ˜„

Hnet-image (1)

์ ‘๊ทผ ๋ฐฉ๋ฒ•

  • ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ํ…Œ์ŠคํŠธ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑ ํ›„ ํŽ˜์ด์ง€๋“ค์„ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.

  • ์ผ๋ถ€ ํŽ˜์ด์ง€๋Š” api์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๊ณ  ์žฅ๋ฐ”๊ตฌ๋‹ˆ์—์„œ๋Š” ๋กœ์ปฌ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๊ฒŒ ๋˜๋Š”๋ฐ ์—ฌ๊ธฐ์—์„œ ํ•„์š”ํ•œ ๋ถ€๋ถ„์— store๋ฅผ ์ด์šฉํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

์žฅ๋ฐ”๊ตฌ๋‹ˆ ํŽ˜์ด์ง€ ( Cart.vue)

    <Header>์žฅ๋ฐ”๊ตฌ๋‹ˆ</Header>
    <main>
      <div>
        <CartItem
        v-for="item in storedCart"
        :id="item.product_no"
        :name="item.name"
        :original_price="item.original_price"
        :description="item.description"
        :key="item.product_no"
        ></CartItem>
      </div>
    </main>
    <OrderBtn/>
  </div>
</template>
<script>
import { mapGetters } from 'vuex';
import Header from '../components/ItemList/Header.vue';
import CartItem from '../components/Cart/CartItem.vue';
import OrderBtn from '../components/OrderBtn/OrderBtn.vue';
export default {
  name: 'OrderPage',
  components: {
    Header, CartItem, OrderBtn,
  },
  computed: {
    ...mapGetters(['storedCart']),

๊ฒฐ์ œ ํŽ˜์ด์ง€ ( Order.vue)

<template>
  <div id='wish-list-page' data-test="order-page">
    <Header/>
    <main>
      <div class="item-detail" data-test="item-list-page">
        <CartItem
        v-for="item in storedCart"
        :id="item.product_no"
        :name="item.name"
        :img="item.image"
        :price="item.price"
        :original_price="item.original_price"
        :description="item.description"
        :key="item.product_no"
        ></CartItem>
      </div>
      <div class="order-cutomer"
        v-for="order in orders"
        :key="order.order_id">
        <div class="order-name">
          <span data-test="test-name">{{order.name}}</span>
        </div>
        <div>
          <input class="order-input" v-model="order.value"/>
        </div>
      </div>
    </main>

    <router-link to="/complete">
      <footer>
      <input class="order-btn" type="button" value="์ฃผ๋ฌธํ•˜๊ธฐ" onclick="idPwCheck()"/>
      </footer>
    </router-link>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import Header from '../components/ItemList/Header.vue';
import CartItem from '../components/Cart/CartItem.vue';

export default {
  name: 'OrderPage',
  components: { Header, CartItem },
  computed: {
    ...mapGetters(['storedCart']),
  },
  data() {
    return {
      orders: [
        {
          order_id: 'o1',
          name: '์ฃผ๋ฌธ์ž๋ช…',
          value: '์ด๋ฆ„์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”',
        },
        {
          order_id: 'o2',
          name: '์ „ํ™”๋ฒˆํ˜ธ',
          value: '์ „ํ™”๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”',
        },
        {
          order_id: 'o3',
          name: '์ˆ˜๋ น ์ฃผ์†Œ',
          value: '์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”',
        },
        {
          order_id: 'o4',
          name: '์š”์ฒญ ์‚ฌํ•ญ',
          value: '๋ฐฐ์†ก ์š”์ฒญ ์‚ฌํ•ญ์„ ์ž…๋ ฅํ•˜์„ธ์š”',
        },
      ],
    };
  },
};
</script>
  • storeํŒŒ์ผ ์ƒ์„ฑ ํ›„ ์žฅ๋ฐ”๊ตฌ๋‹ˆ, ๊ฒฐ์ œํŽ˜์ด์ง€, ๊ฒฐ์ œ์™„๋ฃŒ ํŽ˜์ด์ง€ ์ˆœ์„œ๋Œ€๋กœ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋ชฉ๋ก ์ •๋ณด๊ฐ€ ๊ฒฐ์ œ ํ™”๋ฉด์—์„œ ํ™œ์šฉ์ด ๋˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
  • ๊ฒฐ์ œ ํ™”๋ฉด์—์„œ ํ˜„์žฌ ์‚ฌ์šฉ์ž๊ฐ€ ์ฃผ๋ฌธํ•˜๋Š” ์ƒํ’ˆ๋“ค์˜ ๋ชฉ๋ก์„ ๋‹ค์‹œ ๋ณด์—ฌ์ฃผ๊ณ , ๊ทธ๋กœ ์ธํ•ด ์ด ์˜ˆ์ƒ ๊ธˆ์•ก์ด ๋‚˜์˜ค๋„๋ก ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ๊ฒฐ์ œ ํ™”๋ฉด์—์„œ ๊ตฌ๋งค ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ฒฐ์ œ ์™„๋ฃŒ ํŽ˜์ด์ง€๋กœ ๋„˜์–ด๊ฐ€๋„๋ก ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋Š๋‚€์ 

-์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋‹ด๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์žฅ๋ฐ”๊ตฌ๋‹ˆ์— ์ถ”๊ฐ€๋˜๋Š” ๊ธฐ๋Šฅ์— ๋Œ€ํ•ด ๋งŽ์ด ๊ณ ๋ฏผํ•ด๋ดค์ง€๋งŒ, ๊ตฌํ˜„ํ•˜์ง€ ๋ชปํ•ด ์•„์‰ฝ์Šต๋‹ˆ๋‹ค. ์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด action์„ ์ด์šฉํ•ด์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์žฅ๋ฐ”๊ตฌ๋‹ˆ ํŽ˜์ด์ง€์— ์ „๋‹ฌ๋˜๋„๋ก ์ฝ”๋“œ๋ฅผ ์งฐ๋Š”๋ฐ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ๊ณ„์†ํ•ด์„œ id๊ฐ’์„ ์ฝ์–ด์˜ค์ง€ ๋ชปํ–ˆ๋‹ค๋Š” ์—๋Ÿฌ๊ฐ€ ๋–ด์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ ๊ณผ์ œ๋ฅผ ํ•˜๋ฉด์„œ store์— ๋Œ€ํ•ด ์ดํ•ด๊ฐ€ ๋ถ€์กฑํ•˜๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ๊ณ , ๋˜ํ•œ javascript๋„ ๋งŽ์ด ๋ถ€์กฑํ•˜๋‹ค๋Š” ๊ฒƒ์ด ๋Š๊ปด์กŒ์Šต๋‹ˆ๋‹ค.

code presentation

https://drive.google.com/file/d/11BVIEpn8Z9o1UPhTvPRNPFIcUyqWxOI-/view

About

๐Ÿ†Ž์—์ด๋ธ”๋ฆฌ ์ต์Šคํ„ด์‹ญ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vue 50.1%
  • JavaScript 48.5%
  • HTML 1.4%