vite+vue3+ts创建的项目框架,包括基本的vue-router4、pinia、element-plus、sass、axios、svg图片等基础功能

zhangdechen 9bba71727e README 3 лет назад
.vscode 7ccfd26e2b 提交 3 лет назад
public 7ccfd26e2b 提交 3 лет назад
src 7ccfd26e2b 提交 3 лет назад
.gitignore 7ccfd26e2b 提交 3 лет назад
README.md 9bba71727e README 3 лет назад
index.html 7ccfd26e2b 提交 3 лет назад
package-lock.json 7ccfd26e2b 提交 3 лет назад
package.json 7ccfd26e2b 提交 3 лет назад
tsconfig.json 7ccfd26e2b 提交 3 лет назад
tsconfig.node.json 7ccfd26e2b 提交 3 лет назад
vite.config.ts 7ccfd26e2b 提交 3 лет назад
记录.md 7ccfd26e2b 提交 3 лет назад

README.md

Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Recommended IDE Setup

Type Support For .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

记录


  1. 新建项目 npm create vite@latest vue-vite-ts -- --template vue-ts。
  2. 加载依赖 npm i,启动服务npm run dev。
  3. 修改vite.config.ts 中的配置,defineConfig.server新增配置。 > {
    > hmr:true,
    > port: 9074,
    > open: true,
    > }
  4. 增加路由插件vue-router npm install vue-router@4,使用HTML5模式。 在src路径下新建router文件夹,在main.ts中加载注册使用。
  5. 添加elementui插件 npm install element-plus --save。 在main.ts中引用使用。 > import 'element-plus/dist/index.css'
    > import 'element-plus/theme-chalk/dark/css-vars.css'
  6. 添加pinia插件, npm install pinia --save。 在main.ts中加载注册使用。 > import { createPinia } from 'pinia'
    > const pinia = createPinia();
  7. 添加sass 插件, npm install sass --save
  8. 新增使用svg图片的功能。 使用vite-plugin-svg-icons插件,还需要安装下fast-glob相关依赖。