简体   繁体   English

Laravel Spark Vue.js 模板中的 @ 符号是什么?

[英]What is the @ Symbol in a Laravel Spark Vue.js Template?

In Laravel Spark's template files, you'll occasionally see something like this在 Laravel Spark 的模板文件中,你偶尔会看到类似这样的内容

<span class="help-block" v-show="form.errors.has('name')">
    @{{ form.errors.get('name') }}
</span>

That is, a span that's conditionally toggled visible/invisible based on the form's current errors.也就是说,根据表单的当前错误有条件地切换可见/不可见的跨度。

I understand this part我明白这部分

{{ form.errors.get('name') }}

It's a Vue.js template that will display the string returned by form.errors.get('name') .这是一个 Vue.js 模板,将显示form.errors.get('name')返回的字符串。 However -- what's the @ symbol in front of the template for?然而——模板前面的@符号是干什么用的? I know, as an attribute, @ is a shorthand for v-on .我知道,作为一个属性, @ 是v-on的简写 However,然而,

v-on{{ form.errors.get('name') }}

makes even less sense to me, so I'm guessing the @ symbol does something else here.对我来说更没有意义,所以我猜@符号在这里做了其他事情。 Is this a Vue.js thing?这是 Vue.js 的事情吗? A Laravel Spark thing? Laravel Spark 的东西? Something else?还有什么?

It's because Vue and Laravel Blade use the same syntax for binding dynamic values and expressions.这是因为 Vue 和 Laravel Blade 使用相同的语法来绑定动态值和表达式。

@ into the mustaches expression (in blade file) means that Laravel should ignore it so Vue will take care of It. @进入 mustaches 表达式(在刀片文件中)意味着 Laravel 应该忽略它,以便 Vue 处理它。

Note: If you want to use another templating expression for Vue, check delimiters section in docs - https://v2.vuejs.org/v2/api/#delimiters注意:如果您想为 Vue 使用另一个模板表达式,请查看文档中的分隔符部分 - https://v2.vuejs.org/v2/api/#delimiters

@ symbol its a Laravel thing to inform the Blade rendering engine an expression should remain untouched. @符号它是 Laravel 的事情,用于通知 Blade 渲染引擎一个表达式应该保持不变。 The @ is used in Laravel blade templates. @在 Laravel 刀片模板中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM