Home > Development Tools > VSCode > body text

How to set Vue alias path smart prompt in vscode?

青灯夜游
Release: 2020-09-04 10:27:07
forward
6162 people have browsed it

How to set Vue alias path smart prompt in vscode?

When using the Vue framework for project development, after configuring the path alias in vue.config.js, go to other pages When introducing components, css, and static file paths, using path aliases will not intelligently prompt the path. Although the Path Intellisense plug-in is installed in vscode, it has no effect. This is prone to low-energy problems such as path spelling errors, and will also reduce development efficiency

Related recommendations: "vscode basic tutorial", "vue tutorial

Solution

  • Create a file in the same directory as the projectpackage.jsonjsconfig.json, to solve the problem of not prompting the alias path. (After configuring and saving the file, you need to restart the editor to take effect. And it can only recognize files ending in .vue and .js, css files There is still no prompt with other static files, not recommended!!!)

// .jsconfig.json  
{  
    "compilerOptions": {  
        "baseUrl": ".",  
        "paths": {  
            "@/\*": \['src/\*'\],  
            "a/\*": \["src/assets/\*"\],  
            "c/\*": \["src/components/\*"\],  
            ...  
        }  
     },  
    "include": \["./src/\*\*/\*.vue", "./src/\*\*/\*.js"\], 
    "exclude": \["node\_modules"\]  
}
Copy after login
  • setting.json# in vscode ## Configure Path Intellisence in (This solution is the most preferred, can recognize files in any format, and has the widest coverage. When the alias changes, you only need to modify the configuration)

  • // setting.json  
    "path-intellisense.mappings": {  
        "a": "${workspaceRoot}/src",  
        "c": "${workspaceRoot}/src/components",  
        ...  
    }
    Copy after login
    For more programming-related knowledge, please visit:

    Programming Teaching! !

    The above is the detailed content of How to set Vue alias path smart prompt in vscode?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!