简体   繁体   中英

Laravel+vue.js: using blade/php variable inside Vue variable in laravel blade

It might be a bit over engineering, but so far I can't come up with any other solution. I retrieve a model via axios. The model has a title (English) and may have (or may NOT) its own localized alternative title. The code below is working, but it prepends the localized title with '@' for some reason. So my question is how will I get rid of this '@'?

<label>
<span v-if="(ques.questionLocalized && ques.questionLocalized.{{\App::getLocale()}})">
@{{ques.questionLocalized.<?php echo \App::getLocale();?>}}
</span>  
<span v-else>@{{ques.question}}</span>
<small>({{__('ux.required')}})</small><span class="req">*</span>
</label>

在此处输入图片说明 在此处输入图片说明

try using the @verbatim directive:

@verbatim
<label>
   <span v-if="(ques.questionLocalized && ques.questionLocalized. 
      {{\App::getLocale()}})">
      {{ques.questionLocalized.<?php echo \App::getLocale();?>}}
   </span>  
   <span v-else>{{ques.question}}</span>
   <small>({{__('ux.required')}})</small><span class="req">*</span>
</label>
@endverbatim

you may wrap the HTML in the @verbatim directive so that you do not have to prefix each Blade echo statement with an @ symbol

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