Skip to content
This repository has been archived by the owner on May 3, 2018. It is now read-only.

Hi Guys, i'm tring to pass data from an component to another, but i cant reflact the parent data in to the child, anyone can help me please. #483

Open
patrickcr opened this issue Jan 29, 2016 · 0 comments

Comments

@patrickcr
Copy link

this is my parent component

<template>
  <div>
       <h1>Hello, World</h1>
      <input v-model="user.name">
     <label>Name</label>      
  </div>
    <usercontrol></usercontrol>
</template>
import` UserControl from '../components/UserControl.vue'
    export default {
             components: {
            'usercontrol': UserControl,
            props: ['tab'] 
          },
        data: function() {
            return { 
                user: null,
                tab: 'Shared message'

            }
        },
        created: function () {
            this.$on('child-created', function (child) {
               this.user = child.user;
            })
        }
    };

this is my child component

<template> 
    <div>
        <h1>Authentication Control</h1>
        <input type='text' v-model="user.name"></input>
         <label>parent</label>
       <pre>{{tab }}</pre>
    </div>
</template>

<script>
    export default {
        data: function() {
            return {    `
                user: { name:'Luis' }
            }
        },
        created: function () {
                this.$dispatch('child-created', this)
        },


</script>`<template>
  <div>
       <h1>Hello, World</h1>
      <input v-model="user.name">
     <label>Name</label>      
  </div>
    <usercontrol></usercontrol>
</template>

import` UserControl from '../components/UserControl.vue'
    export default {
             components: {
            'usercontrol': UserControl,
            props: ['tab'] 
          },
        data: function() {
            return { 
                user: null,
                tab: 'Shared message'

            }
        },
        created: function () {
            this.$on('child-created', function (child) {
               this.user = child.user;
            })
        }
    };


i create an Property for Tag in parent, but i can't see the value in the child component, i ne```ed also to know how pass the child data to the parent, i'musin and exmaple from vue, on dispash event to detect when child is cretaed and then i pass the value from child to parent.. Is it no to mush complicated???

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant