流星 ES6 模块相对路径



刚回到流星,并试图弄清楚如何构建一个项目,我陷入了如何处理相对路径的困境,我的项目结构是这样的:

-root
--client
----components
-----layout
...... MainLayout.jsx
--server
--lib
.. routes.jsx

如果我尝试在我的 routes.jsx 文件中导入这样的"./../client/components/layout/MainLayout.jsx' 我收到错误"找不到模块"./../client/components/layout/MainLayout.jsx...

但是,如果我将 MainLayout.jsx 移动到根文件夹,我可以毫无问题地访问这样的组件文件'./../MainLayout.jsx'.

也许我在这里错过了什么? 正如我所说,刚刚回到JS编程。

当路由器.js文件在根目录中时。你有使用而不是

'./../client/components/layout/MainLayout.jsx'

这:

'../client/components/layout/MainLayout.jsx'

或只是:

'../client/components/layout/MainLayout'

最新更新