[英]vscode "Intellisense" and "Go to definition" for not js/ts files
In frontend-development we often import not only javascript/typescript files in javasctipt.在前端开发中,我们经常不仅在 javasctipt 中导入 javascript/typescript 文件。 We import such files using both aliases an relative paths.我们使用两个别名和相对路径导入此类文件。
Example:例子:
import brandsQuery from '~/graphql/queries/brands.gql';
import Button from '~/components/common/button/index.vue';
import Component from './list/index.vue';
By default VS Code doesn't support not js/ts extensions when we import such files - there are no "Intellisense" and "Go to Definitoon" for such files.默认情况下,当我们导入此类文件时,VS Code 不支持非 js/ts 扩展 - 此类文件没有“Intellisense”和“Go to Definitoon”。
I tried such extensions: Path intellisense and Path autocomplete我尝试了这样的扩展: 路径智能感知和路径自动完成
VS Code settings to support alias:支持别名的 VS Code 设置:
"path-intellisense.mappings": {
"~/": "${workspaceFolder}",
},
or或者
"path-autocomplete.pathMappings": {
"~/": "${folder}/",
}
With these extensions we have autocomplete when we write import string.使用这些扩展,我们在编写导入字符串时可以自动完成。 Also for relative paths "Go To Definition" works.也适用于相对路径“转到定义”。
But "Go To Definition" doesn't work for not js-ts files imported using alias.但是“转到定义”不适用于使用别名导入的非 js-ts 文件。
Do you know some way to have both "Intellisense", "Go To Definition" for all extensions that I need in my project?您是否知道某种方法可以让我在项目中需要的所有扩展同时拥有“Intellisense”、“Go To Definition”?
See https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_57.md#go-to-definition-for-non-jsts-files请参阅https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_57.md#go-to-definition-for-non-jsts-files
Many modern JS bundlers and frameworks use
import
statements to import assets such as images and stylesheets.许多现代 JS 捆绑器和框架使用import
语句来导入图像和样式表等资产。 We now support navigating through these imports withgo to definition
:我们现在支持使用go to definition
:
This is probably most useful when using ctrl / cmd click to navigate through your code.这可能在使用ctrl / cmd单击以浏览您的代码时最有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.