【发布时间】:2017-07-11 22:53:12
【问题描述】:
我有一个 React 应用程序,我想为其添加一个 sitemap.xml。我已添加此路由以链接到文件(XML 是我的我的 sitemap.xml):
import XML from './sitemap.xml';
<Route component={XML} path={'/sitemap.xml'} />
我不断收到这个错误,我知道这意味着我需要向我的 webpack 添加一个 xml 加载器:
You may need an appropriate loader to handle this file type.
不确定如何选择 xml 加载器,因为我主要可以找到解析器(xml 到 json),我不确定是否可以在 json 中使用站点地图。另外,有没有其他的原生方式来显示xml文件而不添加任何加载器?
【问题讨论】:
标签: reactjs xml xml-sitemap