App.vue
InfoBox.vue
main.js
<template>
<h2>Example $attrs Object</h2>
<p>There are three elements on the root level of the component, and v-bind="$attrs" adds the "pink" id fallthrough attribute to the p-tag.</p>
<div>
<info-box id="pink"/>
</div>
</template>
<style scoped>
div {
border: solid black 1px;
padding: 0 10px;
width: 250px;
}
</style>
<template>
<h3>Tigers</h3>
<img src="/img_tiger_small.jpg" alt="tiger">
<p v-bind="$attrs">Tigers eat meat and not plants, so they are called carnivores.</p>
</template>
<style>
#pink {
background-color: pink;
border-radius: 15px;
padding: 10px;
}
img {
width: 100%;
border-radius: 15px;
}
</style>
import { createApp } from 'vue'
import App from './App.vue'
import InfoBox from './components/InfoBox.vue'
const app = createApp(App)
app.component('info-box', InfoBox)
app.mount('#app')