1、安装插件:Path Intellisense
2、配置:
{
"path-intellisense.mappings": {
"~": "${workspaceRoot}/src"
}
}
3、修改项目package.json所在同级目录下文件tsconfig.json:
{
"compilerOptions": {
"noImplicitAny": false,
"declaration": false,
"target": "es6",
"removeComments": true,
"preserveConstEnums": true,
"jsx": "react",
"sourceMap": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"lib": [
"dom",
"es2015.promise",
"es5",
"es6",
"es2015.iterable",
"es2015.generator",
"es2015.symbol",
"es7"
],
"paths": {
"~/*": [
"src/apps/*"
]
}
},
"exclude": [
"node_modules"
],
"typeRoots": [
"node_modules/@types"
]
}
4、使用:
import { baseDispatch } from "~/common/src/utils/baseDispatch";