简体   繁体   English

Laravel,blade,vue.js和@if(@ {{}})

[英]Laravel,blade, vue.js and @if (@{{ }})

I am having a problem with variables devielve vue.js me ... I explain better 我在使用变量devielve vue.js时遇到了问题...我解释得更好

        <tr

        @if(@{{users.id}} != 1) // this is the error

        Class="danger"
        @else
        class="success"
        @endif
        >   

I can not define a @if (@ {{user.id in laravel 我无法在laravel中定义@if(@ {{user.id

before defined 在定义之前

@foreach($datos as $dato)
<tbody id={{$dato->id}}>
<tr                                 
@if($dato->id !=1)
class="danger"
@else
Class="success"
@endif >

and it worked but I had to put a select box, and Use varaible vue.js to collect and return the data I... 它可以正常工作,但我必须放置一个选择框,然后使用varaible vue.js收集并返回数据,...

excuse my English is not my mother tongue and hinders me 请问我的英语不是我的母语并且阻碍了我

I do not believe you can use vuejs code (such as your @{{users.id}} ) inside a laravel @if() because everything inside the @if() is being treated as PHP code. 我不相信你可以使用vuejs代码(如您的@{{users.id}}一laravel内@if()因为一切都在里面@if()被当作PHP代码。 If it makes sense in your particular application, make use of vuejs's v-if implementation, such as <div v-if="users.id !== 1"> INSERT WHATEVER HERE </div> 如果在您的特定应用程序中有意义,请使用vuejs的v-if实现,例如<div v-if="users.id !== 1"> INSERT WHATEVER HERE </div>

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

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