絶対的なインポートを作成
1086 ワード
したいのは、迷惑な、長い、退屈なインポートステートメントを取り消すには?
今すぐ作成しますか 次に、プロジェクトルートディレクトリをターミナルに開き、実行します
Learn More About react-jsconfig
import {Card} from './../../components/Card';
ジャストクリエイトjsconfig.json
プロジェクトのルートディレクトリと次のコードのファイル{
"compilerOptions": { "baseUrl": "src" },
"include": ["src"]
}
Yaaそれはあなたのファイルに行くことができますし、以前のコードを置き換えることができます今は非常に簡単ですimport {Card} from 'components/Card';
Make sure you restart the server after creating the
jsconfig.json
file
jsconfig.json
ファイルのすべてのプロジェクトのより効率的な方法で?npx react-jsconfig
It will automatically generate the
jsconfig.json
file for you
Learn More About react-jsconfig
Reference
この問題について(絶対的なインポートを作成), 我々は、より多くの情報をここで見つけました https://dev.to/ashirbadgudu/absolute-import-in-create-react-app-10gaテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol