[Vuejs]-Passing variable form blade template to vue component

0πŸ‘

To pass down data to your components you can use props.

You can do something like:

<component is="component" :zID="{{ $z->id }}"></component>

And then in your Example.vue file you have to define your prop. Then you can access it by this.zID.

<script>
  export default {
  props: ['zId'],
  mounted () {
    // Do something useful with the data in the template
    console.dir(this.zId);
    }
  }
</script>

0πŸ‘

You can make inline templates directly in your blade views.

<component :props="{{ $props }}" inline-template>....</component>

Leave a comment