App.vue
InfoBox.vue
main.js
<template>
<h2>Example $props Object</h2>
<p><input type="text" v-model="name" placeholder="Your name here.."></p>
<p><input type="number" v-model="weight" placeholder="Bag weight.."> kg</p>
<info-box v-bind:bag-owner=name v-bind:bag-weight=weight />
</template>
<script>
export default {
data() {
return {
name: null,
weight: null
}
}
}
</script>
<template>
<div>
<h3>Received Props</h3>
<p>This is the $props object:</p>
<pre>{{ this.$props }}</pre>
</div>
</template>
<script>
export default {
props: [
'bagOwner',
'bagWeight'
]
}
</script>
<style scoped>
div {
border: solid black 1px;
padding: 10px;
max-width: 250px;
margin-top: 20px;
}
pre {
background-color: lightgreen;
font-size: large;
}
</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')