Unescape HTML entities in Javascript?

前端 未结 30 2986
野趣味
野趣味 2020-11-21 05:40

I have some Javascript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form:


30条回答
  •  北荒
    北荒 (楼主)
    2020-11-21 06:05

    You can use Lodash unescape / escape function https://lodash.com/docs/4.17.5#unescape

    import unescape from 'lodash/unescape';
    
    const str = unescape('fred, barney, & pebbles');
    

    str will become 'fred, barney, & pebbles'

提交回复
热议问题