elementui-plus 使用注意点
1,在使用图标注意点,如果使用动态图标需要全局注册图标,不然不会出现
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus' // 引入element-plus
import * as EleIcons from '@element-plus/icons-vue'
const app = createApp(App)
for(const name in EleIcons){ //这个一定写在 createApp后面
app.component(name,EleIcons[name])
}
app.use(router)
.use(store)
.use(ElementPlus, { zIndex: 3000, size: 'small' }) // 使用element-plus
.mount('#app')
el-table 表头循环数据处理
<el-table :data="userList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column
v-for="item in columns"
:key="item.prop"
:prop="item.prop"
:label="item.label"
:width="item.width"
:formatter="item.formatter"
/>
<el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.row)"
>编辑</el-button
>
<el-button
type="danger"
@click="handleDeleteFn(scope.row)"
size="small"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
//定义动态表格-格式
const columns = reactive([
{
label: "用户ID",
prop: "userId",
},
{
label: "用户名",
prop: "userName",
},
{
label: "用户邮箱",
prop: "userEmail",
},
{
label: "用户角色",
prop: "role",
formatter(row, column, value) { //过滤表格内容状态
return {
0: "管理员",
1: "普通用户",
}[value];
},
},
{
label: "用户状态",
prop: "state",
formatter(row, column, value) {
return {
1: "在职",
2: "离职",
3: "请用期",
}[value];
},
},
{
label: "注册时间",
prop: "createTime",
formatter(row, column, value) {
return utils.formateDate(new Date(value));
},
width: 180,
},
{
label: "最后登录时间",
prop: "lastLoginTime",
formatter(row, column, value) {
return utils.formateDate(new Date(value));
},
width: 180,
},
]);
版权声明:本文由Web学习之路发布,如需转载请注明出处。