Laravel templating language Blade and VueJS data binding syntax are very similar.
How can I escape VueJS data binding syntax when in a *.blade.php
file?
Example:
<div>
<!-- Want it with VueJS -->
{{ selectedQuestionDesc }}
</div>
<div>
<!-- Want it with Laravel Blade -->
{{ $selectedQuestionDesc }}
</div>
While asking the question I discovered that you can escape Laravel's Blade by prepending an @
sign before the double brackets {{}}
or the {!! !!}
{!! !!}
html rendering brackets.
So here is the answer:
<div>
<!-- HTML rendering with VueJS -->
@{{ selectedQuestionDesc }}
<!-- Data binding with VueJS -->
@{{ selectedQuestionDesc }}
</div>
<div>
<!-- HTML with Laravel Blade -->
{!! $selectedQuestionDesc !!}
<!-- Variable binding with Laravel Blade -->
{{ $selectedQuestionDesc }}
</div>
要输出真实的HTML,您需要使用v-html指令:
<p>Using v-html directive: <span v-html="rawHtml"></span></p>
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.