vue3安装element-ui
安装
npm install element-plus --save
yarn add element-plus
main.ts
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).mount('#app');
添加 Volar
支持
tsconfig.json
{
"compilerOptions": {
// ...
"types": ["element-plus/global"]
}
}
在页面中使用
<script setup lang="ts">
</script>
<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>
<el-button>中文</el-button>
</template>