react native currency symbol not printing from variable

后端 未结 2 662
栀梦
栀梦 2021-01-28 09:57

I want to print currency symbol from its currency code.
but it not working from variable.

My Code:-

render() {
  var currencyCode =          


        
相关标签:
2条回答
  • 2021-01-28 10:05

    Think you should use unicoded symbols as shown in this tutorial

    0 讨论(0)
  • 2021-01-28 10:23

    This similar question explains all available options. Since dangerouslySetInnerHTML is inapplicable in React Native, there are only two of them.

    HTML entities can be specifically decoded, e.g. with html-entities:

    import { Html5Entities } from 'html-entities';
    const htmlEntities = new Html5Entities();
    
    ...
    
    {htmlEntities.decode(htmlString)}
    

    The problem can be avoided by not storing HTML entities in the first place if possible. Currency symbols are valid Unicode characters and can be stored as such:

    var currencyCode = "€"; // €
    
    0 讨论(0)
提交回复
热议问题