Home > Software engineering >  How to show utf-8 decoded value in vuejs?
How to show utf-8 decoded value in vuejs?

Time:02-10

Requirement: To decode data of utf8 K& #2446;Ler which is possible by v-html attribute in vuejs

Problem: Don't know how to pass displayFullUserName to data-tooltip which holds value Armin K& #2446;Ler so that it will reflect Armin Koler in grey layout.

Finding The below image shows gibberish data K& #2446;Ler, since it is not rendered by v-html. I have a data-tooltip property which shown below as grey over tooltip view. Now, I don't know how to fix this as actual text rendered above was by v-html tag.

enter image description here

 <label
   v-bind:data-tooltip="displayFullUserName"
   v-html="displayFullUserName"
 />

computed() {
return this.displayFullUserName;
}

CodePudding user response:

It worked with below solution

htmlEntity2utf8(s) { 
 const t= document.createElement('span'); t.innerHTML = s; 
 return t.textContent 
}

thanks @Bravo for this.

  •  Tags:  
  • Related