Table of Contents
plug-in
Function
1. Omit writing jump support
2. Alis alias path jump support
3. Components registration alias jump support
4. Component jump support introduced in mixins
5. Global components introduce jump support
Home Development Tools VSCode Practical combat: Develop a plug-in in vscode that supports vue files to jump to definitions

Practical combat: Develop a plug-in in vscode that supports vue files to jump to definitions

Nov 16, 2022 pm 08:43 PM
vscode front end vue.js visual studio code

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.

Practical combat: Develop a plug-in in vscode that supports vue files to jump to definitions

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'
Copy after login

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'
Copy after login

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 &amp;#39;@/components/MyComponent&amp;#39;
export default {
    components: {
        MycoMponentReName: MycoMponent
    }
}
</script>
Copy after login

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 &#39;@/mixins/myMixins&#39;
export default {
    mixins: [myMixins]
}
</script>
Copy after login
// myMixins.js
import MycoMponent from &#39;@/components/MyComponent&#39;
export default {
    components: {
        MycoMponent
    }
}
Copy after login

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>
Copy after login
// main.js
import vue from &#39;vue&#39;
import MycoMponent from &#39;./components/MyComponent&#39;
vue.use(MycoMponent)
Copy after login

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to view word documents in vscode How to view word documents in vscode How to view word documents in vscode How to view word documents in vscode May 09, 2024 am 09:37 AM

First, open the vscode software on the computer, click the [Extension] icon on the left, as shown in ① in the figure. Then, enter [officeviewer] in the search box of the extension interface, as shown in ② in the figure. Then, from the search Select [officeviewer] to install in the results, as shown in ③ in the figure. Finally, open the file, such as docx, pdf, etc., as shown below

How to add files to vscode workspace How to add files to vscode workspace How to add files to vscode workspace How to add files to vscode workspace May 09, 2024 am 09:43 AM

1. First, open the vscode software, click the explorer icon, and find the workspace window 2. Then, click the file menu in the upper left corner and find the add folder to workspace option 3. Finally, find the folder location in the local disk , click the add button

How to enable background updates in vscode How to enable background updates in vscode How to enable background updates in vscode How to enable background updates in vscode May 09, 2024 am 09:52 AM

1. First, after opening the interface, click the file menu in the upper left corner. 2. Then, click the settings button in the preferences column. 3. Then, in the settings page that jumps, find the update section. 4. Finally, click the mouse to check and enable it. Download and install the new VSCode version button in the background on Windows and restart the program.

How to disable wsl configuration file in vscode How to disable wsl configuration file in vscode How to disable wsl configuration file in vscode How to disable wsl configuration file in vscode May 09, 2024 am 10:30 AM

1. First, open the settings option in the settings menu. 2. Then, find the terminal column in the commonly used page. 3. Finally, uncheck the usewslprofiles button on the right side of the column.

How to set animation smooth insertion in VScode VScode tutorial to set animation smooth insertion How to set animation smooth insertion in VScode VScode tutorial to set animation smooth insertion May 09, 2024 am 09:49 AM

1. First, after opening the interface, click the workspace interface 2. Then, in the open editing panel, click the File menu 3. Then, click the Settings button under the Preferences column 4. Finally, click the mouse to check the CursorSmoothCaretAnimation button and save Just set it

How to open workspace trust permissions in Vscode Vscode method to open workspace trust permissions How to open workspace trust permissions in Vscode Vscode method to open workspace trust permissions May 09, 2024 am 10:34 AM

1. First, after opening the editing window, click the configuration icon in the lower left corner 2. Then, click the Manage Workspace Trust button in the submenu that opens 3. Then, find the page in the editing window 4. Finally, according to your office Just check the relevant instructions if required

How to open animation in Vscode Introduction to the method of opening animation in Vscode How to open animation in Vscode Introduction to the method of opening animation in Vscode May 09, 2024 am 10:28 AM

1. First, click to open the settings option in the More menu. 2. Then, find the terminal column under the Features section. 3. Finally, on the right side of the column, click the enableanimation button with the mouse and save the settings.

How to turn on smart commit in vscode Steps to turn on smart commit in vscode How to turn on smart commit in vscode Steps to turn on smart commit in vscode May 09, 2024 am 10:40 AM

Step 1: After opening the vscode software interface, click the settings button in the settings menu below. Step 2: Find the Git option under the Extensions column. Step 3: Click to check the enablesmartcommit button.

See all articles