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";