


Practical combat: Develop a plug-in in vscode that supports vue files to jump to definitions
vscode
itself supports vue file components to jump to definitions, but the support is very weak. Under the configuration of vue-cli
, we can write many flexible usages, which can improve our production efficiency. But it is these flexible writing methods that prevent the functions provided by vscode itself from supporting jumping to file definitions. In order to be compatible with these flexible writing methods and improve work efficiency, I wrote a vscode plug-in that supports Vue files to jump to definitions. [Recommended learning: "vscode tutorial"]
plug-in
vscode supports vue files to jump to defined plug-ins (vue jumper
) has been officially released to the vscode plug-in market. You can go to the vscode plug-in market to download and experience it directly.
Function
This plug-in supports vue-cli to provide us with jump support for many component reference writing methods.
1. Omit writing jump support
When we reference a component, if the name of the component is index.vue
or index.js
, we can omit index.vue or index.js when introducing it. If we use the omitted writing method, vscode itself cannot support jumps, so the plug-in needs to support omitted writing method jumps.
import MycoMponent from '../components/MyComponent' // '../components/MyComponent/index.vue'
2. Alis alias path jump support
Under the configuration of vue-cli (webpack), we can configure alis alias so that we can improve production efficiency , but vscode itself does not support it, so the plug-in needs to support alis alias path jump.
import MycoMponent from '@/components/MyComponent'
3. Components registration alias jump support
vscode itself supports components registration alias jump (if the writing method and alis alias path are omitted when introducing, it will not work. supported), so the plug-in also needs to support components registration alias jump.
<script> import MycoMponent from &#39;@/components/MyComponent&#39; export default { components: { MycoMponentReName: MycoMponent } } </script>
4. Component jump support introduced in mixins
In actual development, we can have many reusable functions extracted tomixins
contains the introduction and registration of components. This vscode itself does not support jumps, so the plug-in supports the introduction of mixins.
<template> <MyComponent /> </template> <script> import myMixins from '@/mixins/myMixins' export default { mixins: [myMixins] } </script>
// myMixins.js import MycoMponent from '@/components/MyComponent' export default { components: { MycoMponent } }
5. Global components introduce jump support
For components registered globally, vscode itself does not support jumps in this case. Since the introduction of global components is relatively complex, the plug-in uses fuzzy search to find the place where the component is defined, and achieves jump support for the introduction of global components.
<template> <MyComponent /> </template> <script>
// main.js import vue from 'vue' import MycoMponent from './components/MyComponent' vue.use(MycoMponent)
For more knowledge about VSCode, please visit: vscode Basic Tutorial!
The above is the detailed content of Practical combat: Develop a plug-in in vscode that supports vue files to jump to definitions. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

React's main functions include componentized thinking, state management and virtual DOM. 1) The idea of componentization allows splitting the UI into reusable parts to improve code readability and maintainability. 2) State management manages dynamic data through state and props, and changes trigger UI updates. 3) Virtual DOM optimization performance, update the UI through the calculation of the minimum operation of DOM replica in memory.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Vue.js is a progressive JavaScript framework released by You Yuxi in 2014 to build a user interface. Its core advantages include: 1. Responsive data binding, automatic update view of data changes; 2. Component development, the UI can be split into independent and reusable components.

How to solve the problem that Chinese comments in Visual Studio Code become question marks: Check the file encoding and make sure it is "UTF-8 without BOM". Change the font to a font that supports Chinese characters, such as "Song Style" or "Microsoft Yahei". Reinstall the font. Enable Unicode support. Upgrade VSCode, restart the computer, and recreate the source file.

Common commands for VS Code terminals include: Clear the terminal screen (clear), list the current directory file (ls), change the current working directory (cd), print the current working directory path (pwd), create a new directory (mkdir), delete empty directory (rmdir), create a new file (touch) delete a file or directory (rm), copy a file or directory (cp), move or rename a file or directory (mv) display file content (cat) view file content and scroll (less) view file content only scroll down (more) display the first few lines of the file (head)

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version
