Home > front end >  How vscode CTRL click associated js code, can use relative paths, but remove the relative path doesn
How vscode CTRL click associated js code, can use relative paths, but remove the relative path doesn

Time:03-23

My project directory is
The project
App
The components
Utils
Scenes
.

I jsconfig json is
 {
"CompilerOptions" : {
"The module", "commonjs",
"Target" : "es2017,"
"JSX" : "react",
"AllowSyntheticDefaultImports" : true,
"BaseUrl" : "./components ",
"Paths" : {
"@/*" : [" app/* "]
}
},
"Exclude" : [" node_modules ", "dist", "next", "cache" and "bundles", "out"],
"Include" : [
"Build/* */*",
"Server/* */*",
"E2e/* */*",
"Pages//* * *,"
"/SRC/* * *,"
"Stories//* * *"
]
}

I a in the app directory index js so reference components under the control of
 import ScrollToTop from "components/ScrollToTop"; 


If this is the written can
 
The import ScrollToTop from "./components/ScrollToTop ";


To ask what should I write, I also installed the path - intellisense plug-in, discovery also futile

 "path - intellisense. The mappings" : {
"@" : "${workspaceRoot}/*"
}

CodePudding user response:

 import ScrollToTop from "components/ScrollToTop"; 


I hope the above method and under the CTRL + click to jump to the source code files, now is not,

CodePudding user response:

Should be solved, jsconfig. Json just write like this, for your reference
 {
"CompilerOptions" : {
"BaseUrl" : ". "
"Paths" : {
"*" : ["./app/* "]
}
}
}
  • Related