๋ฐ์ํ
-์ ์ญ ์ปดํฌ๋ํธ
<!DOCTYPE html>
<head>
<title>Vue Component Registration</title>
</head>
<body>
<div id="app">
<button>์ปดํฌ๋ํธ ๋ฑ๋ก</button>
<my-component></my-component> // ์ ์ญ ์ปดํฌ๋ํธ ํ์
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
Vue.component('my-component', {
template: '<div>์ ์ญ ์ปดํฌ๋ํธ๊ฐ ๋ฑ๋ก๋์์ต๋๋ค!</div>'
})
new Vue({
el: '#app'
})
</script>
</body>
</html>
-์ง์ญ ์ปดํฌ๋ํธ
<!DOCTYPE html>
<head>
<title>Vue Component Registration</title>
</head>
<body>
<div id="app">
<button>์ปดํฌ๋ํธ ๋ฑ๋ก</button>
<my-local-component></my-local-component>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var cmp = {
template: '<div>์ง์ญ ์ปดํฌ๋ํธ๊ฐ ๋ฑ๋ก๋์์ต๋๋ค!</div>'
}
new Vue({
el: '#app',
components: {
'my-local-component': cmp
}
})
</script>
</body>
</html>
์ฆ,
<div id="app">
<button>์ปดํฌ๋ํธ ๋ฑ๋ก</button>
<my-local-component></my-local-component>
</div>
=
<div id="app">
<button>์ปดํฌ๋ํธ ๋ฑ๋ก</button>
<div>์ง์ญ ์ปดํฌ๋ํธ๊ฐ ๋ฑ๋ก๋์์ต๋๋ค!</div>
</div>
๋์ด ๊ฐ์ต๋๋ค.
๋ฐ์ํ
'JavaScript > Vue' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ปดํฌ๋ํธ ๊ฐ ํต์ ๊ณผ ์ ํจ ๋ฒ์ (0) | 2022.06.05 |
---|---|
์ธ์คํด์ค ์ ํจ ๋ฒ์์ ์ง์ญ ์ปดํฌ๋ํธ, ์ ์ญ ์ปดํฌ๋ํธ ๊ฐ ๊ด๊ณ (0) | 2022.06.05 |
Vue Instance Lifecycle (0) | 2022.06.05 |
vue ๊ณต๋ถ (0) | 2022.05.15 |
[Vue.js] <style scoped> (0) | 2022.01.04 |
๋๊ธ