Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何将文件导入到3个文件夹中_Reactjs - Fatal编程技术网

Reactjs 如何将文件导入到3个文件夹中

Reactjs 如何将文件导入到3个文件夹中,reactjs,Reactjs,我正在编辑一个文件Product.jsx,文件路径为:src\components\Products\Product\Product.jsx 我想导入一个CartContext文件,路径为:src\context\CartContext.js 我正在尝试这样做:import{CartContext}来自“../../../context/CartContext” 要导入它,但我得到错误: Failed to compile ./src/components/frontpage/Product.j

我正在编辑一个文件Product.jsx,文件路径为:
src\components\Products\Product\Product.jsx

我想导入一个CartContext文件,路径为:
src\context\CartContext.js

我正在尝试这样做:
import{CartContext}来自“../../../context/CartContext”
要导入它,但我得到错误:

Failed to compile
./src/components/frontpage/Product.js
Module not found: You attempted to import ../../../context/CartContext which falls outside of the project src/ directory. 
Relative imports outside of src/ are not supported.
我从来没有导入错误,也不知道发生了什么


自动导入也不起作用。

结果表明我编辑了错误的文件,该文件位于src\components\frontpage\Product.js中,导致“不在项目src/目录范围内”错误。

该错误表明有问题的文件位于
/src/components/frontpage/Product.js
,您在构建过程中是否移动了文件而不是
src\components\Products\Product\Product.jsx
?非常感谢,您救了我。我正在制作一个新的产品文件,但我没有意识到旧的文件是一个窃听器。这是一个快速解决方案