问题
我想知道在 Vue.js 中是否有替代语法来输出数据,而不是花括号 like the ng-bind Angular directive .
阅读文档,似乎 Vue.js accepts only tag properties使用 v-bind 指令,但我希望它也能与内部 html 一起工作。
上下文
我想使用 PHP 输出数据,并在页面加载后使用 Vue 管理它。想象下一种情况:
我们想要这样的输出:
<div>Hello</div>
首先我们用php输出数据
<div><?php echo $hello_string ?></div>
在那之后,我们希望能够用 Vue 改变内容。当前的语法是;
<div>{{ hello_string }}</div>
我们不能混合这两种语法,所以我需要这样的东西:
<!--Ideal syntax for mixing vue and php--> <div v-bind:innerhtml="hello_string"><?php echo $hello_string ?></div>
感谢您的帮助。
最佳答案
您可以使用 v-text
指令:
<div v-text="hello_string"></div>
<!-- same as -->
<div>{{ hello_string }}</div>
或 v-html
:
<div v-html="html"></div>
<!-- same as -->
<div>{{{ html }}}</div>
关于javascript - Vue.js 中的替代绑定(bind)语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34404843/