📜  在 CRA 中使用 .env - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:23.603000             🧑  作者: Mango

代码示例1
Dotenv is somehow already integrated in your CRA

Just create a .env in root
Inside your .env file don't forget to write "REACT_APP_" before your Variable name
i.e: replace ANYTHING_YOU_WANT = ABcdEfghI45545785 by REACT_APP_ANYTHING_YOU_WANT = ABcdEfghI45545785

In whatever file you want you can refere to your .env with 
`${process.env.REACT_APP_ANYTHING_YOU_WANT}`