【发布时间】:2016-01-09 02:15:36
【问题描述】:
我在 react 中创建了一个日期选择器,我正在尝试将其上传到 NPM,它使用外部 svg,但我无法正确引用该 svg。
所以我的文件目录是这样的:
+-- imgs
| +-- arrow.svg
+-- src
| +-- Datepicker.jsx
| +-- index.js
然后在 Datepicker.jsx 我有<object style={STYLES.arrow} data="../imgs/arrow.svg" type="image/svg+xml" />
但是当我通过 npm 安装它并尝试在项目中使用它时,它说:GET http://localhost:8000/imgs/arrow.svg 404 (Not Found)
它看起来像是在项目的根目录中而不是在模块本身中寻找 imgs 目录,但我不知道如何解决这个问题。
【问题讨论】:
标签: javascript node.js reactjs npm