Question:
I'm doing a test with wordpress rest-api with vue 2.x, and one of the attributes returned is as follows:
"content": {
"rendered": "<P>Bem-vindo ao WordPress. Esse é o seu primeiro post. Edite-o ou exclua-o, e então comece a escrever!</P>\n"
},
There on my page the "p" of the html is displayed. Tried to solve with {{{ }}}
but the version recognizes more that way. And with v-html
also gives an error.
Answer:
In Vue.js 2 you have to use the v-html
which receives the variable that has the HTML you want to use:
var data = { "content": { "rendered": "<P>Bem-vindo ao WordPress. Esse é o seu primeiro post. Edite-o ou exclua-o, e então comece a escrever!</P>\n" } }; var demo = new Vue({ el: '#demo', data: data });
<script src="http://vuejs.org/js/vue.min.js"></script> <div id="demo"> <div v-html="content.rendered"></div> </div>
jsFiddle: http://jsfiddle.net/58toLeoL/