Home > Enterprise >  Show as Html on vuejs
Show as Html on vuejs

Time:02-12

i have json file for translate ( en.json ) and this line :

{ 
  "cancel order": "Hi, How can i <b> Cancel </b> ?",
}


      <div >
    <span >
    
    {{ $t('cancel order') }}
  
    </span>
  </div>

now my result is " Hi, How can i Cancel "

The problem is that the html code does not apply like this code and the tags are displayed exactly without being applied.

CodePudding user response:

You can use the v-html directive to rander raw html.

const htmlcontent = '<h1>Hello</h1>'
<span v-html="htmlcontent">
</span>

https://vuejs.org/guide/essentials/template-syntax.html#raw-html

CodePudding user response:

use this :

<div v-html="$t('cancel order')"></div>
  • Related