[英]Import without specifying index in react.js
How can I configure my react application so I do not need to specify index on my imports? 如何配置我的react应用程序,这样我就不需要在导入中指定索引了?
-src
|- app.jsx
|- views
|- sample
|- sample.css
|- sample-container.jsx
|- sample-view.jsx
|- index.jsx
Currently I have to do this: 目前,我必须这样做:
import Sample from "src/views/sample/index"
What I want to do is this: 我想做的是这样的:
import Sample from "src/views/sample"
I used create-react-app
for initial set up and already ran npm run eject
我使用create-react-app
进行初始设置,并且已经运行了npm run eject
Looks to be an issue with creating new index.jsx
file while the server is started. 在服务器启动时创建新的index.jsx
文件index.jsx
是一个问题。 Shutting down the server and starting it back up ( npm start
) seems to resolve the issue. 关闭服务器并重新启动服务器( npm start
)似乎可以解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.