Laravel Blade Template passing data to Vue JS component

后端 未结 3 1242
挽巷
挽巷 2020-12-31 12:12

I am having a problem passing a property using Vuejs ~1.0 to a child component from a Laravel Blade template. If I pass something in plain text it works just fine, but when

相关标签:
3条回答
  • 2020-12-31 12:47

    If you are passing a variable to the component, then use:

    <my-component :video= "{{ json_encode($stuff) }}" ></my-component>
    

    Don't forget the double quotes or the result would be unpredictable for things like objects.

    0 讨论(0)
  • 2020-12-31 12:51

    Look like I just figured it out, it seems that I was missing the colon before video, so it should have appeared like so:

    <my-component :video="stuff"></my-component>

    0 讨论(0)
  • 2020-12-31 13:03

    If you are passing model then do this:

    <my-component :video="{{ $stuff->toJson() }}" inline-template></my-component>
    
    0 讨论(0)
提交回复
热议问题