简体   繁体   中英

How to inject html using mustache

Following is my content:

const content = Testing mutache with html. click {{{link}}}.

Following is my mustache code:

Mustache.render(content, {link:'<a href="http://google.com">here</a>'});

On screen, it is rendering as :

Testing mutache with html. click <a href="http://google.com">here</a>.

What am I doing wrong?

The answer is you don't use the mustache in this way. To render HTML into a template you would have to use the rawHTML method as described here:

https://v2.vuejs.org/v2/guide/syntax.html#Raw-HTML

to Quote "The double mustaches interprets the data as plain text, not HTML. In order to output real HTML, you will need to use the v-html directive"

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM