Vue - 학습 기록 앱 만들기 1 : Resources & Styling

2023. 8. 5. 15:49·📘 Frontend/Vue

Learning Resource + Styling

App.vue는 Root Component이기 때문에 Template에 최대한 MarkUp이 없게 만들어야 합니다.

Data 프로퍼티에 더미 데이터 배열을 만들고 그 데이터를 Stored-Resource로 넘겨주고,

Stored-Resource는 배열을 받고 순회 하면서 데이터를 Learning-Resource로 바인딩합니다.


Style 부분은 전역 스타일 설정은 왠만하면 App.vue에 지정하고 나머지 컴포넌트들에는 scoped style을 적용하였습니다.


App.vue

<template>  
  <ul>  
    <stored-resources  
        :resources="storedResources"  
    ></stored-resources>  
  </ul>  
</template>  

<script>  
import StoredResources from "@/components/Learing-Resources/StoredResources";  

export default {  
  components: { StoredResources },  

  data() {  
    return {  
      storedResources: [  
        {  
          id: 'official-guide',  
          title: 'Official Guide',  
          description: 'The Official Vue.js Documentation',  
          link: 'https://vuejs.org'  
        },  
        {  
          id: 'google',  
          title: 'Google',  
          description: 'The Official Google Documentation',  
          link: 'https://google.org'  
        },  
      ]  
    };  
  },  
}  
</script>  

<style>  
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');  

* {  
  box-sizing: border-box;  
}  

html {  
  font-family: 'Roboto', sans-serif;  
}  

body {  
  margin: 0;  
}  
</style>

LearningResource.vue

<template>  
  <li>  
    <div>  
      <header>  
        <h3>{{ title }}</h3>  
        <button>Delete</button>  
      </header>  
    </div>  

    <p>{{ description }}</p>  

    <nav>  
      <a :href="link">View Resource</a>  
    </nav>  
  </li>  
</template>  

<script>  
export default {  
  props: ['title', 'description', 'link'],  

}  
</script>  

<style scoped>  
li {  
  margin: auto;  
  max-width: 40rem;  
}  

header {  
  display: flex;  
  justify-content: space-between;  
  align-items: center;  
}  

h3 {  
  font-size: 1.25rem;  
  margin: 0.5rem 0;  
}  

p {  
  margin: 0.5rem 0;  
}  

a {  
  text-decoration: none;  
  color: #ce5c00;  
}  

a:hover,  
a:active {  
  color: #c89300;  
}  
</style>

StoredResources.vue

<template>  
  <ul>  
    <learning-resource  
        v-for="res in resources"  
        :key="res.id"  
        :title="res.title"  
        :description="res.description"  
        :link="res.link"  
    ></learning-resource>  
  </ul>  
</template>  

<script>  
import LearningResource from "@/components/Learing-Resources/LearningResource";  

export default {  
  components: { LearningResource },  

  props: ['resources'],  
}  
</script>  

<style scoped>  
ul {  
  list-style: none;  
  margin: 0;  
  padding: 0;  
  margin: auto;  
  max-width: 40rem;  
}  
</style>

결과물

img

저작자표시

'📘 Frontend > Vue' 카테고리의 다른 글

Vue - 학습 기록 앱 만들기 3 : Base Button Component  (0) 2023.08.05
Vue - 학습 기록 앱 만들기 2 : UI/Layout Components  (0) 2023.08.05
Vue - 빠른 학습을 위한 기록 잠정 중단  (0) 2023.08.05
Vue - Component Custom Event ($emit())  (0) 2023.08.03
Vue - Props  (0) 2023.08.03
'📘 Frontend/Vue' 카테고리의 다른 글
  • Vue - 학습 기록 앱 만들기 3 : Base Button Component
  • Vue - 학습 기록 앱 만들기 2 : UI/Layout Components
  • Vue - 빠른 학습을 위한 기록 잠정 중단
  • Vue - Component Custom Event ($emit())
신건우
신건우
조용한 개발자
  • 신건우
    우주먼지
    신건우
  • 전체
    오늘
    어제
    • 분류 전체보기 (422)
      • 📘 Frontend (71)
        • Markup (1)
        • Style Sheet (2)
        • Dart (8)
        • Javascript (12)
        • TypeScript (1)
        • Vue (36)
        • React (2)
        • Flutter (9)
      • 📘 Backend (143)
        • Java (34)
        • Concurrency (19)
        • Reflection (1)
        • Kotlin (29)
        • Python (1)
        • Spring (42)
        • Spring Cloud (5)
        • Message Broker (5)
        • Streaming (2)
        • 기능 개발 (5)
      • 💻 Server (6)
        • Linux (6)
      • ❌ Error Handling (11)
      • 📦 Database (62)
        • SQL (31)
        • NoSQL (2)
        • JPQL (9)
        • QueryDSL (12)
        • Basic (4)
        • Firebase (4)
      • ⚙️ Ops (57)
        • CS (6)
        • AWS (9)
        • Docker (8)
        • Kubernetes (13)
        • MSA (1)
        • CI & CD (20)
      • 📚 Data Architect (48)
        • Data Structure (10)
        • Algorithm (8)
        • Programmers (17)
        • BaekJoon (5)
        • CodeUp (4)
        • Design Pattern (4)
        • AI (0)
      • ⚒️ Management & Tool (8)
        • Git (7)
        • IntelliJ (1)
      • 📄 Document (10)
        • Project 설계 (6)
        • Server Migration (3)
      • 📄 책읽기 (2)
        • 시작하세요! 도커 & 쿠버네티스 (2)
      • 🎮 Game (4)
        • Stardew Vally (1)
        • Path of Exile (3)
  • 블로그 메뉴

    • 링크

      • Github
    • 공지사항

    • 인기 글

    • 태그

      React #Markdown
      GStreamer #Pipeline
      Lock #Thread #Concurrency
    • 최근 댓글

    • 최근 글

    • hELLO· Designed By정상우.v4.10.0
    신건우
    Vue - 학습 기록 앱 만들기 1 : Resources & Styling
    상단으로

    티스토리툴바