从容器导入组件(从作用域之外)



我是个新手,在这个基本问题上遇到了一些麻烦。

从HomeLander.js-如何导入按钮和p?正如预期的那样,它们不在同一范围内。有没有一种巧妙的方法可以做到这一点?

我的目录是这样构造的:

  • 组件/
    • 按钮/
      • index.js
    • P/
      • index.js
  • 容器/
    • HomeLander/
      • index.js
  • Index.js("Main"js文件(

你可以试试这个

import Button from '../../Components/Button'; (given Button component is default export)
import { Button } from '../../Components/Button'; (if Button component is not default export)

与"p"相同

最新更新