Laravel刀片模板将数据传递到Vue JS组件 [英] Laravel Blade Template passing data to Vue JS component

查看:413
本文介绍了Laravel刀片模板将数据传递到Vue JS组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Vuejs〜1.0将属性从Laravel Blade模板传递到子组件时遇到问题.如果我以纯文本形式传递某些内容,则效果很好,但是当我尝试传递js属性,数组或对象时,则根本不起作用.我目前有一个带有自定义组件的刀片文件,如下所示:

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 I try to pass a js property, array, or object it doesn't work at all. I currently have a blade file with a custom component which looks like this:

<my-component video="@{{ stuff }}"></my-component>

如果我遗漏了@{{ }},唯一要传递的是字符串stuff,而如果遗漏了@,则显然会出现刀片错误,但是如果使用@{{ stuff }},那么我得到的只是字符串{{ stuff }}.我显然错过了一些东西,但无法告诉我我要去哪里错了.预先感谢.

If I leave out the @{{ }} the only thing that will be passed is the string stuff, and if I leave out the @, I obviously get a blade error, but if I use @{{ stuff }}, then all I get is the string {{ stuff }}. I'm obviously missing something, but can't tell where I'm going wrong. Thanks in advance.

推荐答案

就像我刚刚发现的一样,似乎我在视频之前就没了冒号,所以它应该看起来像这样:

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>

这篇关于Laravel刀片模板将数据传递到Vue JS组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆