前端工程 点击引入路径跳进文件
新建文件 jsconfig.json (放在根目录)
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"exclude": ["node_modules", "dist"]
}
项目配置文件加别名
下面是 vue.config.js 配置
configureWebpack: {
resolve: {
//配置导入路径自动导入index文件
extensions: ['.js', '.vue', '.json'],
alias: {
'@': resolve('src')
}
}
},
配置webpack全局导入 moment mapState 等常用插件(和上面不是一个功能)
const webpack = require('webpack');
module.exports = {
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
mapState: ['vuex', 'mapState'],
moment: 'moment',
}),
],
},
};