在 Laravel Blade 中转义 VueJS 数据绑定语法?
Escape VueJS data binding syntax in Laravel Blade?
Laravel 模板语言 Blade 和 VueJS 数据绑定语法非常相似。
如何在 *.blade.php
文件中转义 VueJS 数据绑定语法?
示例:
<div>
<!-- Want it with VueJS -->
{{ selectedQuestionDesc }}
</div>
<div>
<!-- Want it with Laravel Blade -->
{{ $selectedQuestionDesc }}
</div>
在问这个问题时我发现你可以通过在双括号 {{}}
或 {!! !!}
html渲染括号。
所以这里是答案:
<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>
Laravel 模板语言 Blade 和 VueJS 数据绑定语法非常相似。
如何在 *.blade.php
文件中转义 VueJS 数据绑定语法?
示例:
<div>
<!-- Want it with VueJS -->
{{ selectedQuestionDesc }}
</div>
<div>
<!-- Want it with Laravel Blade -->
{{ $selectedQuestionDesc }}
</div>
在问这个问题时我发现你可以通过在双括号 {{}}
或 {!! !!}
html渲染括号。
所以这里是答案:
<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>