【Vue | initial】 创建初始化项目

chuang'jian'chu创建初始化

1. 使用命令创建

官方官网快速上手

cmd 复制代码
npm create vite@latest 

This command will install and execute create-vue, the official Vue project scaffolding tool. You will be presented with prompts for several optional features such as TypeScript and testing support:

  • 询问是否继续 ;请填写项目名
  • 是否要添加 ts (typescript)
  • 选择其他依赖
  • 跳过
  • 是否选择示例代码

初始化完成

因此,我们可以采用"架构师视角" 较为自动化的初始化

架构师视角

cmd 复制代码
# 架构师写在公司自动化脚本里的命令,瞬间生成标准项目
 npm create vue@latest my-company-project -- --ts --router --pinia --eslint --prettier

2. 进入创建的目录中,安装依赖(基础依赖)

Once the project is created, follow the instructions to install dependencies and start the dev server:

cmd 复制代码
cd <your-project-name>
npm install
npm run dev

粗心粗心???

基础依赖 npm install 是根据这个文件进行执行安装的package.json

You should now have your first Vue project running!

3. 安装"全家桶"依赖

安装"全家桶"依赖 npm install axios element-plus @element-plus/icons-vue

4.安装并配置 Tailwind CSS V4

npm install tailwindcss @tailwindcss/vite

5. 配置 vite.config.ts

typescript 复制代码
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

import tailwindcss from '@tailwindcss/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),  // register the plugin
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
相关推荐
晓13132 小时前
React篇——第七章 React 19 编译器深度解析
前端·javascript·react.js
Csvn2 小时前
错误边界处理
前端·react.js
im_AMBER2 小时前
手撕代码之事件委托
前端·javascript·面试
用户8113581881202 小时前
React全家桶笔记(三):React进阶 — 事件处理、表单与生命周期
前端
用户8113581881202 小时前
React全家桶笔记(二):React组件核心 — State、Props、Refs
前端
Jenlybein2 小时前
一文了解 pnpm,并快速上手操作!
前端·javascript·npm
大萝卜呼呼2 小时前
Next.js第二课 - 项目结构详解 - 优栈
前端·next.js
skywalkzf2 小时前
全志 V853 开发:lunch 不显示项目列表问题排查与解决
前端·chrome
踩着两条虫2 小时前
VTJ.PRO 在线应用开发平台的项目模板(Web、H5、UniApp)
前端·低代码·ai编程