[Vuejs]-Passing a Variable in vue.js Component Modal Window

1๐Ÿ‘

โœ…

Iโ€™m not sure that you are trying pass data into the component or get data from the component.

If you are passing value to the component:

Vue.component('account', {
  props: ['data'],
  template: '<h3>{{ data }}</h3>'
})
<account data="some-value"></account>

If you are trying emit value out from the component:

Inside your component

<button v-on:click="$emit('onChildClick', 'some-value')">
  Click me
</button>

When you call your component

<Account v-if="showModal" :showModal=showModal v-on:onChildClick="getChildValue"></Account>
methods: {
  getChildValue: function (payload) {
    console.log(payload)
  }
}

You can learn more about pass data between components in this article, please visit https://www.smashingmagazine.com/2020/01/data-components-vue-js/

Hope this help.

๐Ÿ‘คAh Dii

Leave a comment