[Vuejs]-Linking a text field in a child component to a parent component's props in VueJS

1👍

First, you need to remove the $event parameter

<TweetDeck v-on:messageFromTweetDeck="msgReceived"/>

Second, you can optimize the data format passed to the parent component:

sendTweet() {
  this.$emit("messageFromTweetDeck",
    { tweet: this.yourTweet, name: this.yourName, handle: this.yourHandle }
  );
}

And then modify your msgReceived method:

msgReceived(childData) {
  this.tweets.push(childData);
}

Link: codesandbox

Hope to help you:)

👤sugars

Leave a comment