如何在 ReactJs 中使用 SVG 和图像回退?
How to use SVGs and image fallbacks with ReactJs?
我目前正在为我的一个项目使用 ReactJs。由于在谈到 ReactJs 时我们都在考虑组件,我们如何在 React 应用程序中处理 SVGs/fallbacks?
我们是否为每个 SVG 构建组件?或者你的 React 用户是否有不同的方式来构建它们?我只想通过最佳实践来接近它!
如果有人帮助我,我会很高兴:)
看看material-ui library's approach to SVG support. They have a SvgIcon component which you should be able to reuse. Their approach is having the common implementation separated out in the SvgIcon component and then having individual component wrappers for each unique SVG icon。
我目前正在为我的一个项目使用 ReactJs。由于在谈到 ReactJs 时我们都在考虑组件,我们如何在 React 应用程序中处理 SVGs/fallbacks?
我们是否为每个 SVG 构建组件?或者你的 React 用户是否有不同的方式来构建它们?我只想通过最佳实践来接近它!
如果有人帮助我,我会很高兴:)
看看material-ui library's approach to SVG support. They have a SvgIcon component which you should be able to reuse. Their approach is having the common implementation separated out in the SvgIcon component and then having individual component wrappers for each unique SVG icon。