Passing different values

We can pass all possible data types to props. Some of them are:

  • Number:
<Student Age=23 /> // Static 
<Student :Age='age' /> // Dynamic
  • String:
<Student name='Same  /> // Static 
<Student :name='name' /> // Dynamic
  • Boolean:
<Student StudentPass='false' />
<Student :StudentPass="stud1.pass" />
  • Array:
<Student student-marks='[89, 38, 83]' />
<Student :student-marks="stud1.marks" />
  • Objects :
<Students student1="{ name: 'sam', age: '23' }" /> 
<Students :student1="students.stud1" />

Vue.js Prop Passing Details

Vue.js Props are used to pass data to the component. For passing details to props we have to first declare props. To declare the prop name we choose a name that is more descriptive of the value that it holds. In this article, we will see the Prop passing the details in Vue.js. The following are the different properties of the prop:

Table of Content

  • Prop Name Casing
  • static vs. Dynamic Props
  • Passing different values
  • Binding Multiple Properties Using an Object

We will explore the above-mentioned Props in Vue.js in detail, along with understanding their basic implementation through the illustration.

Similar Reads

Prop Name Casing

We have different types of conventions for writing the names of props such as camelCasel, kebab-case, PascalCase, etc. We generally use camelCase to long prop name because it allows us to directly reference them in dom because they are valid JavaScript identifiers....

static vs. Dynamic Props

We have different ways to pass details to Prop Sometimes it can be static and sometimes it can be dynamic. Static props are a value that is fixed throughout the existence of a web page. Like below:...

Passing different values

We can pass all possible data types to props. Some of them are:...

Binding Multiple Properties Using an Object

If we want to pass all pros in one object we can bind all properties using Objects and v-bind directive...