简体   繁体   中英

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

In Laravel Spark's template files, you'll occasionally see something like this

<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') . However -- what's the @ symbol in front of the template for? I know, as an attribute, @ is a shorthand for 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? A Laravel Spark thing? Something else?

It's because Vue and Laravel Blade use the same syntax for binding dynamic values and expressions.

@ into the mustaches expression (in blade file) means that Laravel should ignore it so Vue will take care of It.

Note: If you want to use another templating expression for Vue, check delimiters section in docs - https://v2.vuejs.org/v2/api/#delimiters

@ symbol its a Laravel thing to inform the Blade rendering engine an expression should remain untouched. The @ is used in Laravel blade templates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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