<aside> ❗ App.vue(부모 컴포넌트)에서 자식 요소로써 사용할 수 있는 또 다른 vue 파일
</aside>
<template>
<MyBtn>
Banana
</MyBtn>
</template>
<script>
**import MyBtn from '~/components/MyBtn'**
export default {
**components: {
MyBtn
}**
}
// 부모 컴포넌트( App.vue)
<template>
<MyBtn <u>**color="royalblue"**</u>>
Banana
</MyBtn>
</template>
// 자식 컴포넌트 (MyBtn.vue)
export default {
<u>**props**</u>: {
color: {
type: String,
default: ''
}
}
}
// 부모 컴포넌트
<template>
<MyBtn style="color: red">
Banana
</MyBtn>
</template>
// 자식 컴포넌트
<template>
<h1 :style="<u>**this.attrs.style**</u>" :class="<u>**this.attrs.class**</u>">
</template>
또는
<template>
<h1 <u>**v-bind="this.$attrs"**</u>>
</template>
// 부모 컴포넌트
<template>
<MyBtn <u>**@click**</u>="log"></MyBtn>
</template>
// 자식 컴포넌트
<template>
<h1 @click="<u>**$emit('click', $event)**</u>"></h1>
<script>
export default {
<u>**emits</u>: [
'click'
]**
}
</script>