Superscript Text in React Native

后端 未结 5 426
孤独总比滥情好
孤独总比滥情好 2020-12-06 02:56

I would like to style text as superscript in React Native. How would this be accomplished? Is there a way to make use of the Javascript sup() string method to r

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-06 03:35

    Javascripts sub() function will only surround your text with tags and they are recognized as text in RN. You would need to build your own function like:

    export default class Test extends Component {
        sub = (base, exponent) => {
            return 
                
                    {base}
                
                
                    {exponent}
                
            
        }
    
        render() {
            return(
                
                    {(() => 'hello'+'world'.sub())()}
                    {(() => this.sub('hello','world'))()}
                    {(() => this.sub('2','6'))()}
                
            );
        }
    }
    

提交回复
热议问题