elementUI相关总结

1.Vue+Element中的表格根据属性值来渲染不同的样式,状态设置不同颜色
在这里插入图片描述

正则判断写法:
<el-table-column prop="workOrderStatusName" label="状态" align="center">
					<template slot-scope="scope">
						<strong :style="{ color: scope.row.workOrderStatus === 1||scope.row.workOrderStatus === 2 ? '#409EFF':scope.row.workOrderStatus === 6 ? '#13ce66' : '#ED3F14' }">{{ scope.row.workOrderStatusName}}</strong>
					</template>
</el-table-column>
拓展:
//两种状态的判断
<el-table-column label="当前"
   prop="status">
    <template slot-scope="scope">
        <span :style="{ color: scope.row.status === 1 ? '#cccccc' : '#ED3F14' }">{{ scope.row.status === 1 ? '男' : '女' }}</span>
    </template>
</el-table-column>
//三种状态的判断
<el-table-column 
    label="当前" 
    prop="status"
    >
    <template slot-scope="scope">
        <span :style="{ color: scope.row.status === 0 ? '#ff':scope.row.status === 1 ? '#cccccc' : '#ED3F14' }">{{ scope.row.status == 0 ? '已过期':scope.row.status === 1 ? '授权' : '未授权' }}</span>
    </template>
</el-table-column>

2.el-table表格高度根据页面高度自适应
在这里插入图片描述

<el-table :max-height="tableHeight" :data="tableData" highlight-current-row border stripe>	</el-table>
data() {
			return {
				tableHeight: window.innerHeight - 200,
		}	
created() {
			window.addEventListener('resize', this.getTableHeight)
		},
destroyed() {
			window.removeEventListener('resize', this.getTableHeight)
		},
methods: {
			getTableHeight() {
				this.tableHeight = window.innerHeight - 200
			},
			}

3.点击table表格颜色加深当前行
在这里插入图片描述

<el-table highlight-current-row ></el-table>
css:
 /* 选中表格改变原始背景色注意得在table增加highlight-current-row才能生效 .BOX 是当前页面div*/
 .BOX tr.current-row>td {
 	background-color: #93bfab !important;
 	color: #fff;
 	font-weight: 700;
 }

4.禁用日期时间选择
在这里插入图片描述

elementUI版本::picker-options

<div>
						<span>查询日期:</span>
						<el-date-picker :clearable="false" :picker-options="pickerOptions" style="width: 18rem;"
							size="small" v-model="formSearch3.date" type="daterange" value-format='timestamp'
							ange-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
						</el-date-picker>
					</div>
data() {
			return {
				pickerOptions: {
					disabledDate(time) {
						// return time.getTime() > Date.now() - 24 * 60 * 60 * 1000
						return time.getTime() > Date.now() 
					}
				}
			}
		},

element-plus版本:disabled-date

<div>
				<span class="titleEvn">记录起止时间:</span>
				<el-config-provider :locale="locale">
					<el-date-picker v-model="formSearch.date" type="datetimerange" start-placeholder="开始日期"
						end-placeholder="结束日期" :disabled-date="disabledDate" value-format="YYYY-MM-DD HH:mm:ss">
					</el-date-picker>
				</el-config-provider>
			</div>
		data() {
			return {
				formSearch: {
					date: []
					// date: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
					// date: [new Date(new Date().toLocaleDateString()).getTime() - (24 * 60 * 60 * 1000 * 30), new Date(
					// 	new Date()
					// 	.toLocaleDateString()).getTime()]
				},
				disabledDate(date) {
					return date.getTime() > new Date()
				},
			}
		},

5.如何将elementUI动态渲染的表格里面某列数据进行标红处理
在这里插入图片描述

<el-table min-height="200px" :data="state.tableData.list_Row" :max-height="state.tableHeight" stripe style="width: 100%">
				<el-table-column
					align="center"
					v-for="(item, index) in state.tableData.list_Col"
					:key="index"
					:prop="item.prop"
					:width="item.width"
					:label="item.label"
					:cell-style="cellStyle"
				>
					<template #default="scope" v-if="item.label=='总结果'">
						<span v-if="scope.row.item0 == 'NG'||scope.row.item0 == ' NG'" style="background: #ff0000; color: white">{{ scope.row.item0 }}</span>
					</template>
				</el-table-column>
			</el-table>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
ElementUI是基于Vue.js开发的一套前端组件库,常用于快速构建Web界面。而所谓的离线安装,就是将ElementUI相关资源文件下载到本地,然后在项目中引入这些本地资源文件,以避免每次都通过网络加载组件库。 要进行ElementUI离线安装,首先需要下载所需的资源文件。可以到ElementUI的官方网站(https://element.eleme.cn/)或者GitHub仓库(https://github.com/ElemeFE/element)上找到最新的资源文件下载链接。在下载时选择合适的版本和所需的组件。 下载完成后,将资源文件解压到项目的指定目录中,通常是放在项目的静态资源文件夹下。解压后会有多个文件夹和文件,其中重要的是dist目录,它包含了组件库的相关代码和样式。 接下来,在项目的入口文件(通常是main.js或index.js)中引入ElementUI的组件和样式。可以使用import关键字导入所需的组件,然后使用Vue.use()方法注册组件。同时,还要在样式文件中引入ElementUI的样式文件,以便正确显示组件的样式。 最后,就可以在项目中使用ElementUI的组件了。可以在Vue组件中按需引入所需的组件,然后在模板中使用它们。在使用时,可以参考ElementUI的官方文档(https://element.eleme.cn/)来查找组件的具体使用方法和属性。 总结起来,ElementUI的离线安装包括下载资源文件、解压到项目目录、引入组件和样式以及使用组件等步骤。通过离线安装,可以更加方便地在项目中使用ElementUI的组件,提高开发效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值