1.安装element-plus
npm install element-plus --save --force
2.安装完成之后在项目的main.js文件中添加引入
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
// 导入elementplus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
createApp(App).use(ElementPlus)
createApp(App).use(router).mount('#app')
3.在app.vue中引入element button
<el-button>I am ElButton</el-button>
<el-row class="mb-4">
<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>
</el-row>
注意此时引入有可能无法显示按钮的样式,刚入门,目前还不懂原因
4.找到<script></script>,在里面添加按需导入的代码
<script>
import { ElButton } from 'element-plus'
export default ({
name: 'app',
components: {
ElButton
}
})
</script>
5.运行新建的项目,此时就可以看到 按钮的样式了
网友评论