<small id='VJ2w1'></small><noframes id='VJ2w1'>

  1. <legend id='VJ2w1'><style id='VJ2w1'><dir id='VJ2w1'><q id='VJ2w1'></q></dir></style></legend>

      • <bdo id='VJ2w1'></bdo><ul id='VJ2w1'></ul>
    1. <i id='VJ2w1'><tr id='VJ2w1'><dt id='VJ2w1'><q id='VJ2w1'><span id='VJ2w1'><b id='VJ2w1'><form id='VJ2w1'><ins id='VJ2w1'></ins><ul id='VJ2w1'></ul><sub id='VJ2w1'></sub></form><legend id='VJ2w1'></legend><bdo id='VJ2w1'><pre id='VJ2w1'><center id='VJ2w1'></center></pre></bdo></b><th id='VJ2w1'></th></span></q></dt></tr></i><div id='VJ2w1'><tfoot id='VJ2w1'></tfoot><dl id='VJ2w1'><fieldset id='VJ2w1'></fieldset></dl></div>

      <tfoot id='VJ2w1'></tfoot>

      vscode“智能感知"和“转到定义"对于非 js/ts 文件

      时间:2023-09-07

        <tbody id='efpow'></tbody>
        <legend id='efpow'><style id='efpow'><dir id='efpow'><q id='efpow'></q></dir></style></legend>

      • <i id='efpow'><tr id='efpow'><dt id='efpow'><q id='efpow'><span id='efpow'><b id='efpow'><form id='efpow'><ins id='efpow'></ins><ul id='efpow'></ul><sub id='efpow'></sub></form><legend id='efpow'></legend><bdo id='efpow'><pre id='efpow'><center id='efpow'></center></pre></bdo></b><th id='efpow'></th></span></q></dt></tr></i><div id='efpow'><tfoot id='efpow'></tfoot><dl id='efpow'><fieldset id='efpow'></fieldset></dl></div>
        • <bdo id='efpow'></bdo><ul id='efpow'></ul>
        • <small id='efpow'></small><noframes id='efpow'>

                <tfoot id='efpow'></tfoot>
                本文介绍了vscode“智能感知"和“转到定义"对于非 js/ts 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在前端开发中,我们经常不仅在 javasctipt 中导入 javascript/typescript 文件.我们使用两个别名和相对路径导入此类文件.

                例子:

                从'~/graphql/queries/brands.gql'导入brandQuery;从 '~/components/common/button/index.vue' 导入按钮;从'./list/index.vue'导入组件;

                默认情况下,当我们导入此类文件时,VS Code 不支持非 js/ts 扩展 - 没有智能感知".和转到 Definitoon"对于此类文件.

                我尝试了这样的扩展:

                <块引用>

                这可能在使用 ctrl/cmd 时最有用单击以浏览您的代码.

                In frontend-development we often import not only javascript/typescript files in javasctipt. 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.

                I tried such extensions: Path intellisense and Path autocomplete

                VS Code settings to support alias:

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

                Do you know some way to have both "Intellisense", "Go To Definition" for all extensions that I need in my project?

                解决方案

                See 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. We now support navigating through these imports with go to definition:

                This is probably most useful when using ctrl/cmd click to navigate through your code.

                这篇关于vscode“智能感知"和“转到定义"对于非 js/ts 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:img 设置 flex-grow 填充 flex 容器剩余空间,导致 flex 内部溢出 flex 容器 下一篇:GlideJS - 使用带有 React 组件的幻灯片时的奇怪行为

                相关文章

                <i id='7d0Ud'><tr id='7d0Ud'><dt id='7d0Ud'><q id='7d0Ud'><span id='7d0Ud'><b id='7d0Ud'><form id='7d0Ud'><ins id='7d0Ud'></ins><ul id='7d0Ud'></ul><sub id='7d0Ud'></sub></form><legend id='7d0Ud'></legend><bdo id='7d0Ud'><pre id='7d0Ud'><center id='7d0Ud'></center></pre></bdo></b><th id='7d0Ud'></th></span></q></dt></tr></i><div id='7d0Ud'><tfoot id='7d0Ud'></tfoot><dl id='7d0Ud'><fieldset id='7d0Ud'></fieldset></dl></div>

                1. <small id='7d0Ud'></small><noframes id='7d0Ud'>

                    <legend id='7d0Ud'><style id='7d0Ud'><dir id='7d0Ud'><q id='7d0Ud'></q></dir></style></legend><tfoot id='7d0Ud'></tfoot>
                      <bdo id='7d0Ud'></bdo><ul id='7d0Ud'></ul>