How to import file from outside /components in react

前端 未结 3 1079
情书的邮戳
情书的邮戳 2021-01-22 02:03

My folder structure is as follows:

In my App.Js (which is under the components folder), I have:

import variables from \'/src/EnvVariables/varia         


        
3条回答
  •  庸人自扰
    2021-01-22 02:23

    Have you tried to import with the relative path? (with one or more ../ sections)

    import variables from "../EnvVariables/variables.json"
    

    Of course, if you prefer absolute paths you can setup https://webpack.js.org/configuration/resolve/, but I believe for first, you should try the first solution

提交回复
热议问题