vue3 + elementui + typescript

451 阅读1分钟

安装vue脚手架

npm install -g @vue/cli

确定vue版本

$ vue -V
@vue/cli 5.0.6

创建Vue3项目

vue create hello

选择vue3

Vue CLI v5.0.6
? Please pick a preset: (Use arrow keys)
> Default ([Vue 3] babel, eslint)
  Default ([Vue 2] babel, eslint)
  Manually select features

添加typescript支持

vue add typescript

一路yes

添加element-ui

  • 安装element-ui
npm install element-plus
  • 修改main.ts,引入element-ui
import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
const app = createApp(App)
app.use(ElementPlus, { size: 'small', zIndex: 3000 })
app.mount('#app')