Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Node.js기본
- 성장기
- 열공하자
- localStorage
- ServerSentEvent
- EventSource
- Lag
- partitioning
- node.js
- 개발자
- PostgreSQL
- Partition
- node.js란
- 파티셔닝
- SSE
- frontend
- mariadb
- 실시간알림
Archives
- Today
- Total
써치킴의 우당탕탕 개발 블로그
[Vue.js][Ch4][영화검색 사이트] About 본문
1. about.js 작성
/* 개발자 / 사용자와 관련된 데이터를 취급하는 파일 */
export default {
namespaced: true,
// state는 객체 데이터를 반환
// 함수로 만든 이유?
// 객체 데이터는 배열 데이터와 동일하게 참조형 데이터이다.
// => 데이터의 불변성을 유지하려면 함수로 만들어서 반환해야 데이터가 고유해진다.
state: () => ({
name: 'EJKIM',
email: 'ejkim.dev@gmail.com',
blog: 'https://searchkim.tistory.com',
phone: '+82-10-6631-6158',
image: 'https://tistory3.daumcdn.net/tistory/4669904/skinSetting/4a03d2214cc74c7cb8c599a9b55c1a81'
})
}
- state 옵션은 함수를 이용해 객체 데이터를 반환한다.
- 함수를 이용하는 이유는?
- 객체 데이터는 배열 데이터와 동일하게 참조형 데이터이다. 데이터의 불변성을 유지하려면 함수를 이용해서 반환해야 데이터가 고유해진다.
- 함수를 이용하는 이유는?
2. about.vue 작성
<template>
<div class="about">
<div class="photo">
<Loader
v-if="imageLoading"
absolute
/>
<img
:src="image"
:alt="name">
</div>
<div class="name">
{{ name }}
</div>
<div>{{ email }}</div>
<div>{{ blog }}</div>
<div>{{ phone }}</div>
</div>
</template>
<script>
import Loader from '~/components/Loader'
export default {
data() {
return {
imageLoading: true
}
},
computed: {
image() {
return this.$store.state.about.image;
},
name() {
return this.$store.state.about.name;
},
email() {
return this.$store.state.about.email;
},
blog() {
return this.$store.state.about.blog;
},
phone() {
return this.$store.state.about.phone;
}
},
// 라이프사이클에선 비동기를 사용하면 안된다.
// 그럴 땐, 별도의 비동기 메소드를 만들어서 라이플 사이클에서 호출하면 된다.
mounted() {
this.init();
},
methods: {
async init() {
await this.$loadImage(this.image);
this.imageLoading = false;
}
}
}
</script>
<style lang="scss" scoped>
@import "~/scss/main"; /* 부트스트랩을 사용할 수 있게 import */
.about {
text-align: center;
.photo {
width: 250px;
height: 250px;
margin: 40px auto 20px;
padding: 30px;
border: 10px solid $gray-300;
border-radius: 50%;
box-sizing: border-box;
background-color: $gray-200;
position: relative;
img {
width: 100%;
border-radius: inherit;
}
}
.name {
font-size: 40px;
font-family: "Oswald", sans-serif;
margin-bottom: 20px;
}
}
</style>
출력
'완벽하게 Vue.js' 카테고리의 다른 글
[Vue.js][Ch4][영화검색 사이트] 부트스트랩 Breakpoint (반응형) (0) | 2022.05.01 |
---|---|
[Vue.js][Ch4][영화검색 사이트] 404 Page Not Found (0) | 2022.05.01 |
[Vue.js][Ch4][영화검색 사이트] Nav 경로 일치 및 활성화 (0) | 2022.04.29 |
[Vue.js][Ch4][영화검색 사이트] 영화 포스터가 없는 경우 예외 처리 (0) | 2022.04.28 |
[Vue.js][Ch4][영화검색 사이트] Vue 플러그인(이미지 로드 이벤트) (0) | 2022.04.28 |
Comments