[英]How to import a file from another folder in react?
tsx file in below path以下路径中的 tsx 文件
app/frontend/src/pages/main/_form/output.tsx应用程序/前端/src/pages/main/_form/output.tsx
now i want to import this file "output.tsx" into "Parent.tsx" file which is in below path现在我想将此文件“output.tsx”导入到路径下方的“Parent.tsx”文件中
app/frontend/src/pages/Lists/_form/formSteps/Step1/Parent.tsx app/frontend/src/pages/Lists/_form/formSteps/Step1/Parent.tsx
how can i import output.tsx file in Parent.tsx file我如何在 Parent.tsx 文件中导入 output.tsx 文件
i have tried below我在下面尝试过
import {something] from '../../output.tsx';从'../../output.tsx'导入{something];
but the path seems to be errorneous.但路径似乎是错误的。 could someone help me out with this.
有人可以帮我解决这个问题。 thanks
谢谢
The common root is pages
which is 4 levels up from Parent.tsx
, so below should work fine公共根是从
Parent.tsx
向上 4 级的pages
,所以下面应该可以正常工作
../../../../main/_form/output.tsx
Also if its a default import use like this此外,如果它是这样的默认导入使用
import Output from '../../../../main/_form/output.tsx
; import Output from '../../../../main/_form/output.tsx
;
use like that import {something} from '../../output.tsx';像这样使用 import {something} from '../../output.tsx';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.