λ°μν
Named View(λ€μλ λ·°)λ νΉμ νμ΄μ§λ‘ μ΄λνμ λ μ¬λ¬ κ°μ μ»΄ν¬λνΈλ₯Ό λμμ νμνλ λΌμ°ν λ°©μμ΄λ€.
λ€μλ λ·°λ κ°μ λ 벨μμ μ¬λ¬ κ°μ μ»΄ν¬λνΈλ₯Ό ν λ²μ νμνλ€.
<!DOCTYPE html>
<head>
<title>Vue Named View Sample</title>
</head>
<body>
<div id="app">
<router-view name="header"></router-view>
<router-view></router-view>
<router-view name="footer"></router-view>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router@3.0.1/dist/vue-router.js"></script>
<script>
var Body = { template: `<div>This is Body</div>` }
var Header = { template: `<div>This is Header</div>` }
var Footer = { template: `<div>This is Footer</div>` }
var router = new VueRouter({
routes: [
{
path: '/',
components: {
default: Body,
header: Header,
footer: Footer,
}
}
]
})
var app = new Vue({
router
}).$mount('#app')
</script>
</body>
</html>
λ°μν
'JavaScript > Vue' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Vue.js] Vueμμμ μλ°μ€ν¬λ¦½νΈ ννμ (0) | 2022.06.06 |
---|---|
[Vue.js] v-bind (0) | 2022.06.06 |
Nested Router (0) | 2022.06.06 |
[Vue.js] router URLμ ν΄μ κ°(#)μ μμ λ λ² (0) | 2022.06.06 |
Vue router (0) | 2022.06.06 |
λκΈ