Created
November 28, 2019 09:58
-
-
Save ksy90101/2b8517824c22de0f1ddbabbb70d59e77 to your computer and use it in GitHub Desktop.
[Groom] Vue.js로 시작하는 SPA 개발 Chapter06 - Ex2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ko"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>[Groom]Vue.js로 시작하는 SPA개발 - Chapter06 - Ex2</title> | |
<!-- Vue.js 추가 --> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
</head> | |
<body> | |
<!-- Component를 안 쓴 v-for --> | |
<div id="app"> | |
<div v-for="post in posts" :key="post.idx"> <!-- v-for 사용, key값 설정--> | |
<h3>{{ post.title }}</h3> | |
<p>{{ post.description }}</p> | |
</div> | |
</div> | |
<script> | |
let vm = new Vue({ // Vue 생성 | |
el: "#app", | |
data: { | |
posts: [ // posts라는 배열 생성 | |
{ | |
idx: 1, | |
title: "Blog Post 1", | |
description: "Lorem Inpum 1" | |
}, | |
{ | |
idx: 2, | |
title: "Blog Post 2", | |
description: "Lorem Inpum 2" | |
}, | |
{ | |
idx: 3, | |
title: "Blog Post 3", | |
description: "Lorem Inpum 3" | |
} | |
] | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment