如要自动引入Vue组件,首先需安装VSCode拓展: Vetur
vue
在根目录添加 jsconfig.json
。
每次修改jsconfig.json
后需重启该VSCode窗口node
{ "include": [ "./src/**/*" ], }
同上,需更新 jsconfig.json
git
{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": [ "./src/*" ] }, }, "include": [ "./src/**/*", ], }
lodahs
为例,安装 lodash
: npm install lodash
jsconfig.json
{ "compilerOptions": { "checkJs": true, }, "include": [ "node_modules/lodash/*" ], }
Ctrl/Command + .
),选择JS模块
注意:
checkJs
可能会引发部分项目语法报错,若有报错可以使用下面的方法做为替代方案。
Npm Intellisense
自动引入node_modules中的JSNpm Intellisense
Npm Intellisense
{ "npm-intellisense.scanDevDependencies": true, "npm-intellisense.importES6": true, "npm-intellisense.importQuotes": "'", "npm-intellisense.importLinebreak": ";\r\n", "npm-intellisense.importDeclarationType": "const", }
Ctrl/Command + Shift + P
): Npm Intellisense: Import module
后, 选择引入包自动引入Vue组件和JS模块后,按住Ctrl/Command
点击路径可直接跳到该文件github
文章原始发布于:个人博客npm