Javascript Vue.js中的替代绑定语法 问题:

Javascript Vue.js中的替代绑定语法 问题:,javascript,php,angularjs,vue.js,Javascript,Php,Angularjs,Vue.js,我想知道在Vue.js中输出数据是否有替代语法,而不是大括号 阅读文档时,似乎使用了v-bind指令,但我希望它也能使用内部html 上下文 我希望使用PHP输出数据,并且在加载页面后,使用Vue对其进行管理。想象下一种情况: 我们需要以下输出: <div>Hello</div> 你好 首先,我们用php输出数据 <div><?php echo $hello_string ?></div> 之后,我们希望能够使用Vue更改内容。当前语法为 <div>{{ he

我想知道在Vue.js中输出数据是否有替代语法,而不是大括号

阅读文档时,似乎使用了v-bind指令,但我希望它也能使用内部html

上下文 我希望使用PHP输出数据,并且在加载页面后,使用Vue对其进行管理。想象下一种情况:

我们需要以下输出:

<div>Hello</div> 你好 首先,我们用php输出数据

<div><?php echo $hello_string ?></div> 之后,我们希望能够使用Vue更改内容。当前语法为

<div>{{ hello_string }}</div> {{{hello_string}} 我们不能混合这两种语法,所以我需要这样的东西:

<!--Ideal syntax for mixing vue and php--> <div v-bind:innerhtml="hello_string"><?php echo $hello_string ?></div> &中尉--混合vue和php的理想语法--> 感谢您的帮助。

Vue.component({
Vue.component({
    el:'#app',
    data:function(){
        return {
            hello_string:"<?php echo json_encode($hello_string) ?>"
        };
    }
});
el:“#应用程序”, 数据:函数(){ 返回{ 你好,字符串:“ }; } });
然后在HTML中:

<div id="app><div>{{ hello_string }}</div></div>
您可以使用以下指令:

<div v-text="hello_string"></div>
<!-- same as -->
<div>{{ hello_string }}</div>

v-html可能会导致XSS攻击,因此需要小心
<div v-html="html"></div>
<!-- same as -->
<div>{{{ html }}}</div>