快速入门:
然后我在src下创建了一个Button.vue文件,再去Element-plus官网查找组件的源码
常用组件
表格:
<script lang="ts" setup>
import {
Delete,
Edit,
} from '@element-plus/icons-vue'
const tableData = [
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
}, {
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
}
]
</script>
<template>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="title" label="文章标题" />
<el-table-column prop="category" label="分类" />
<el-table-column prop="time" label="发表时间" />
<el-table-column prop="state" label="状态" />
<el-table-column label="操作" width="180">
<div>
<el-button type="primary" :icon="Edit" circle />
<el-button type="danger" :icon="Delete" circle />
</div>
</el-table-column>
</el-table>
</template>
分页条:
如果想用把英语边为中文需要在main.js中导包:
import locale from ‘element-plus/dist/locale/zh-cn.js’
然后在使用的时候:
app.use(ElementPlus,{locale})
但是这个次序好像有点问题!
但是发现这个100条也太夸张了 也修改一下
将这里改为你喜欢的就好了
剩下的都是一样自己尝试着修改
<script lang="ts" setup>import { ref } from 'vue'
import type { ComponentSize } from 'element-plus'
const currentPage1 = ref(5)
const currentPage2 = ref(5)
const currentPage3 = ref(5)
const currentPage4 = ref(4)
const pageSize2 = ref(100)
const pageSize3 = ref(100)
const pageSize4 = ref(10)
const size = ref<ComponentSize>('default')
const background = ref(false)
const disabled = ref(false)
const total = ref(20)
const handleSizeChange = (val: number) => {
console.log(`${val} items per page`)
}
const handleCurrentChange = (val: number) => {
console.log(`current page: ${val}`)
}
import {
Delete,
Edit,
} from '@element-plus/icons-vue'
const tableData = [
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
}, {
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
}
]
</script>
<template>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="title" label="文章标题" />
<el-table-column prop="category" label="分类" />
<el-table-column prop="time" label="发表时间" />
<el-table-column prop="state" label="状态" />
<el-table-column label="操作" width="180">
<div>
<el-button type="primary" :icon="Edit" circle />
<el-button type="danger" :icon="Delete" circle />
</div>
</el-table-column>
</el-table>
<el-pagination class="el-p" v-model:current-page="currentPage4" v-model:page-size="pageSize4"
:page-sizes="[10, 15, 20]" :size="size" :disabled="disabled" :background="background"
layout="jumper,total, sizes, prev, pager, next" :total="total" @size-change="handleSizeChange"
@current-change="handleCurrentChange" />
</template>
<style scoped>
.el-p {
margin-top: 20px;
display: felx;
justify-content: flex-end;
}
</style>
表单:
卡片:
<script lang="ts" setup>
import { reactive } from 'vue'
const formInline = reactive({
user: '',
region: '',
date: '',
})
const onSubmit = () => {
console.log('submit!')
}
import { ref } from 'vue'
import type { ComponentSize } from 'element-plus'
const currentPage1 = ref(5)
const currentPage2 = ref(5)
const currentPage3 = ref(5)
const currentPage4 = ref(4)
const pageSize2 = ref(100)
const pageSize3 = ref(100)
const pageSize4 = ref(10)
const size = ref<ComponentSize>('default')
const background = ref(false)
const disabled = ref(false)
const total = ref(20)
const handleSizeChange = (val: number) => {
console.log(`${val} items per page`)
}
const handleCurrentChange = (val: number) => {
console.log(`current page: ${val}`)
}
import {
Delete,
Edit,
} from '@element-plus/icons-vue'
const tableData = [
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
},
{
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
}, {
title: '标题1',
category: '时事',
time: '2000-01-01',
state: '已发布',
}
]
</script>
<template>
<el-card style="max-width:100%">
<div class="card-header">
<span>文章管理</span>
<el-button type="primary">发布文章</el-button>
</div>
<div style="margin-top: 20px;">
<hr>
</div>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="文章分类:">
<el-select v-model="formInline.region" placeholder="请选择" clearable>
<el-option label="时事" value="时事" />
<el-option label="篮球" value="篮球" />
</el-select>
</el-form-item>
<el-form-item label="发布状态:">
<el-select v-model="formInline.region" placeholder="请选择" clearable>
<el-option label="已发布" value="已发布" />
<el-option label="草稿" value="草稿" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="default" @click="onSubmit">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="title" label="文章标题" />
<el-table-column prop="category" label="分类" />
<el-table-column prop="time" label="发表时间" />
<el-table-column prop="state" label="状态" />
<el-table-column label="操作" width="180">
<div>
<el-button type="primary" :icon="Edit" circle />
<el-button type="danger" :icon="Delete" circle />
</div>
</el-table-column>
</el-table>
<el-pagination class="el-p" v-model:current-page="currentPage4" v-model:page-size="pageSize4"
:page-sizes="[10, 15, 20]" :size="size" :disabled="disabled" :background="background"
layout="jumper,total, sizes, prev, pager, next" :total="total" @size-change="handleSizeChange"
@current-change="handleCurrentChange" />
</el-card>
</template>
<style scoped>
.el-p {
margin-top: 20px;
display: felx;
justify-content: flex-end;
}
.demo-form-inline .el-input {
--el-input-width: 220px;
}
.demo-form-inline .el-select {
--el-select-width: 220px;
}
.card-header {
display: flex;
justify-content: space-between;
}
</style>
标签:category,01,const,2000,Element,state,Plus,ref
From: https://blog.csdn.net/2301_79602614/article/details/143824263