[Vuejs]-Vuejs-parent and child components

0👍

parent component and child component is not the same, child component feeding by the parent as the prop, you can mutate data to child component by parent and emit data from child to parent for changed the prop.

for example:

 ////parent.vue////

 <parent-component>
    <child-component :item="items"  :profile="profile"></child-component>
</parent-component>

export default {
  data(){
      items: {
      id: 0,
      name: 'Negar'
 },
 data2: {
     id: 1,
     name: 'Hozhabr^_^'
 }
},
 profile: {
    url: 'http://www.alibaba.com',
    company: 'alibaba',
    city: 'Tehran'
  }
}

//// child.vue /////
<template> 
    Item: {{items}}

    profile: {{profile}}
</template>

export default {
  props:['items', 'profile']
}

Leave a comment