Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Developing Vue with VSCode

Developing Vue with VSCode

Visual Studio Code (abbreviated as VS Code) is a free, open-source code editor developed by Microsoft that supports multiple programming languages and provides features such as syntax highlighting, intelligent code completion, code refactoring, and debugging.

Visual Studio Code has built-in support for the core building blocks of Vue.js: HTML, CSS, and JavaScript.

VS Code has a built-in terminal that lets you run command-line tools such as npm and yarn directly in the editor, making project building and management convenient.

If you want a richer Vue.js development environment, you can install the Volar and Volar for TypeScript extensions, which provide Vue.js intelligent hints.

If you are not yet familiar with VS Code or have not installed it, you can refer to:VSCode Tutorial.


Create a Vue Project

Open the terminal or command prompt and enter the following command:

npm create vue@latest 

The system will prompt you to enter a project name; here we enter runoob-vue3-app:

Vue.js - The Progressive JavaScript Framework



? 请输入项目名称: › runoob-vue3-app

After that, there will be some options; you can choose according to your needs, or simply press Enter all the way through:

Vue.js - The Progressive JavaScript Framework



> 请输入项目名称: … runoob-vue3-app

> 是否使用 TypeScript 语法? … 否 / 是

> 是否启用 JSX 支持? … 否 / 是

> 是否引入 Vue Router 进行单页面应用开发? … 否 / 是

> 是否引入 Pinia 用于状态管理? … 否 / 是

> 是否引入 Vitest 用于单元测试? … 否 / 是

> 是否要引入一款端到端(End to End)测试工具? › 不需要

> 是否引入 ESLint 用于代码质量检测? › 否



正在初始化项目 /Users/tianqixin/runoob-vue3-app...



Project initialization is complete, you can execute the following commands:



  cd runoob-vue3-app

  npm install

  npm run dev

After the project is created, enter the project folder and install dependencies:

cd runoob-vue3-app

npm install

Installing dependencies may also take a few minutes.

Enter the following command to quickly start your Vue application:



npm run dev

Open http://localhost:5173 in your browser; it will display as follows:

Press Ctrl+C to stop the vue-cli-service server.


Open the Vue Project in VS Code

From the terminal or command prompt, navigate to the Vue project folder runoob-vue3-app that we created, then use the code command to open the project in VS Code:



cd runoob-vue3-app

code .

VS Code will start and display your Vue project in the file explorer, as shown below:

Next, expand the src folder and select the App.vue file; the bottom-right of the status bar will also prompt you to install the Vue - Official extension to support .vue files:

Just choose to install it.

After installation, .vue files are recognized as the Vue.js file type and support the following language features:

IntelliSense

When typing code in App.vue, you will see IntelliSense for HTML, CSS, and Vue.js-specific syntax (such as v-bind and v-for).

In the script section, you can also see hints for Vue.js-related JavaScript features, such as the computed property.

Go to Definition / Peek Definition

With the installed Volar extension, VS Code supports the Vue.js language service.

Place the cursor on App, right-click and choose Peek Definition to view definition information, or press the shortcut ⌥F12.

You will see a pop-up window displaying the definition information for App.

Press the Esc key to close the peek window.

Modify and Run "Hello World"

In App.vue, replace the HelloWorld component's msg custom attribute text with "Hello World!":

Example

Save the App.vue file (shortcut ⌘S or Ctrl+S), then restart the server with the following command:



npm run dev

In the browser, you will see the page display "Hello World!".


More Related Tools