vite+vue+ts+element-plus从零开发管理后台框架(01)-初始化

创建项目

使用npm view create-vite versions可以查看所有版本

npm create vite@5.4.0 vueelementplus -- --template vue-ts

运行项目

cd vueelementplus
npm install
npm run dev

VITE v5.3.4  ready in 670 ms

➜  Local:   http://localhost:5173/
➜  Network: use --host to expose
➜  press h + enter to show help

浏览器访问 http://localhost:5173/

初始页

Node.js TypeScript 类型支持

npm install @types/node -D

删除无用资源

删除src/assets/vue.svgsrc/components/HelloWorld.vue

统一和初始化浏览器样式

安装normalize.css

npm install normalize.css@8.0.1

编辑src/main.ts,导入normalize.css

import { createApp } from 'vue'

import 'normalize.css/normalize.css'

编辑src/style.css,内容如下。

* {
  margin: 0;
  padding: 0;

  /* border 和 padding 包含在 width 和 height 之内 */
  box-sizing: border-box;
}

添加 Element Plus

安装

npm install element-plus@2.7.7

编辑src/main.ts,完整引入。

import { createApp } from 'vue'

import 'normalize.css/normalize.css'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

import './style.css'

import App from './App.vue'


const app = createApp(App)

app.use(ElementPlus)
app.mount('#app')

编辑tsconfig.app.jsoncompilerOptions字段添加如下配置,支持Vue - Official插件。

"noFallthroughCasesInSwitch": true,

"types": ["element-plus/global"]

编辑src/App.vue,测试按钮组件。

<template>
  <el-button>Default</el-button>
  <el-button type="primary">Primary</el-button>
  <el-button type="success">Success</el-button>
  <el-button type="info">Info</el-button>
  <el-button type="warning">Warning</el-button>
  <el-button type="danger">Danger</el-button>
</template>

element-plus测试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值