Embedding SVG into ReactJS

后端 未结 6 1229
春和景丽
春和景丽 2020-11-28 03:20

Is is possible to embed SVG markup into a ReactJS component?

render: function() {
  return (
    
      

        
6条回答
  •  伪装坚强ぢ
    2020-11-28 04:04

    If you want to load it from a file, you may try to use React-inlinesvg - that's pretty simple and straight-forward.

    import SVG from 'react-inlinesvg';
    
    }
      onLoad={(src) => {
        myOnLoadHandler(src);
      }}
    >
      Here's some optional content for browsers that don't support XHR or inline
      SVGs. You can use other React components here too. Here, I'll show you.
      
    
    

提交回复
热议问题