Posts Learn Components Snippets Categories Tags Tools new About
/

Vue Js Use v-bind for Prop Destructuring

Use v-bind as a kind of a “prop destructuring” instead of passing multiple object properties into a component as props

Created on Sep 11, 2021

44 views

Use v-bind as a kind of a “prop destructuring” instead of passing multiple object properties into a component as props.
<template>
  <post
    :id="post.id"
    :title="post.title"
    :author="post.author"
  />
  
  <!-- This (↑) is the same as this (↓) -->

  <post v-bind="post" />
</template>

<script>
// <post> component definition
export default {
  props: {
    id: Number,
    title: String,
    author: Object
  }
}
</script>

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for Vue Js Use v-bind for Prop Destructuring

)