react 路径跳转组件不跳转_解决vscode 开发react 导入绝对路径 无法跳转的问题

相对路径可正常跳转

import { namespace, getStaffs as actionGetStaffs, addStaffs as actionAddStaffs } from '../../redux/actions/staff'

但是在webpack配置alias使用绝对路径后无法跳转

webpack配置:

resolve: {

modules: [path.join(__dirname, 'src'), 'node_modules'],

extensions: ['.js', '.jsx', '.json', '.scss', '.css'],

alias: {

src: path.join(__dirname, 'src'),

},

plugins: [

new ModuleScopePlugin(appSrc, [appPackageJson]),

],

},

// 文件导入

import { namespace, getStaffs as actionGetStaffs, addStaffs as actionAddStaffs } from 'src/redux/actions/staff'

解决办法:

需要添加一个jsconfig文件,如下:

{

"compilerOptions": {

"baseUrl": "./", // all paths are relative to the baseUrl

"paths": {

"src/*" : ["src/*"]

}

}

}

参考地址:

你可能感兴趣的:(react,路径跳转组件不跳转)