Skip to content

快速上手

通过vue-cli创建项目

安装脚手架

sh
npm install @vue/cli -g

创建项目

sh
npm create vue@latest
sh
# For Yarn Modern (v2+)
yarn create vue@latest

# For Yarn ^v4.11
yarn dlx create-vue@latest

这一指令将会安装并执行 create-vue,它是 Vue 官方的项目脚手架工具。你将会看到一些诸如 TypeScript 和测试支持之类的可选功能提示:

js
✔ Project name: … <your-project-name>
✔ Add TypeScript? … No / Yes
✔ Add JSX Support? … No / Yes
✔ Add Vue Router for Single Page Application development? … No / Yes
✔ Add Pinia for state management? … No / Yes
✔ Add Vitest for Unit testing? … No / Yes
✔ Add an End-to-End Testing Solution? … No / Cypress / Nightwatch / Playwright
✔ Add ESLint for code quality? … No / Yes
✔ Add Prettier for code formatting? … No / Yes
✔ Add Vue DevTools 7 extension for debugging? (experimental) … No / Yes

Scaffolding project in ./<your-project-name>...
Done.

TIP

如果不确定是否要开启某个功能,你可以直接按下回车键选择 No

运行项目

在项目被创建后,通过以下步骤安装依赖并启动开发服务器:

sh
cd <your-project-name>
npm install
npm run dev
sh
cd <your-project-name>
yarn
yarn dev

打包项目

当准备将应用发布到生产环境时,请运行:

sh
npm run build
sh
yarn build

上次更新于: