์ง์ญ/์ ์ญ ์ปดํฌ๋ํธ์ ์ฐจ์ด์ ?
์ ์ญ ์ปดํฌ๋ํธ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์์ผ๋ก ๋ง๋ค์ด ์ ์ญ์ผ๋ก ์ฌ์ฉํด์ผํ ๋์๋ง ์ฌ์ฉ. ์ ์ญ์ด๋ฏ๋ก, ์ธ์คํด์ค๋ฅผ ๋ง๋ค๋๋ง๋ค ์์ฑํด ์ค ํ์๊ฐ ์๋ค.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<!-- ์๋์์ ๋ฑ๋กํ ์ปดํฌ๋ํธ๋ฅผ ์ ์ฉ์ํด-->
<app-header></app-header>
<app-footer></app-footer>
</div>
<div id="app2">
<app-header></app-header>
<app-footer></app-footer> //์ค๋ฅ๊ฐ ๋๋ฉด์ ํ๋ฉด์ ๋ณด์ด์ง ์๋๋ค. footer๋ ์ง์ญ ์ปดํฌ๋ํธ์ด๊ณ app๊ณผ ๋งคํ๋์ด ์์ผ๋ฏ๋ก
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
//์ ์ญ ์ปดํฌ๋ํธ
Vue.component('app-header', {
template : '<h1>Header1</h1>'
});
//์ง์ญ ์ปดํฌ๋ํธ
new Vue({
el : '#app',
components :
{
'app-footer' : {
template : '<footer>footer</footer>'
}
}
});
new Vue({
el : '#app2'
})
</script>
</body>
</html>