当前位置:网站首页>封装和使用通用的工具栏组件
封装和使用通用的工具栏组件
2022-08-10 08:22:00 【cc&】
封装:
1.绘制好静态结构(components中)
<template>
<div class="page-tools">
<!-- 左侧 -->
<div class="left">
<div class="tips">
<i class="el-icon-info" />
<span>本月: 社保在缴 公积金在缴</span>
</div>
</div>
<div class="right">
<!-- 右侧 -->
<el-button type="primary" size="small">历史归档</el-button>
<el-button type="primary" size="small">导出</el-button>
</div>
</div>
</template>
<script>
export default {}
</script>
<style lang="scss" scoped>
.page-tools {
display: flex;
justify-content: space-between;
align-items: center;
.tips {
line-height: 34px;
padding: 0px 15px;
border-radius: 5px;
border: 1px solid rgba(145, 213, 255, 1);
background: rgba(230, 247, 255, 1);
i {
margin-right: 10px;
color: #409eff;
}
}
}
</style>
2.插槽优化(重要)
使用:具名插槽 <slot name=''left"/>
<template>
<el-card>
<div class="page-tools">
<!-- 左侧 -->
<div class="left">
<div class="tips">
<i class="el-icon-info" />
<slot name="left" />
</div>
</div>
<!-- 右侧 -->
<div class="right">
<slot name="right" />
</div>
</div>
</el-card>
</template>
3.组件使用(重要)
<template>
<div class="employees-container">
<div class="app-container">
<page-tools>
<!-- 插入到left插槽位置 -->
<template #left>
<span>总计100条数据</span>
</template>
<!-- 插入到right插槽位置 -->
<template #right>
<el-button type="primary" size="small">导入excel</el-button>
<el-button type="primary" size="small">导出excel</el-button>
<el-button type="primary" size="small">新增员工</el-button>
</template>
</page-tools>
</div>
</div>
</template>
<script>
import PageTools from '@/components/PageTools'
export default {
components:{
PageTools
}
}
</script>
使用优化:
1.提供统一注册的入口文件(components/index.js)
import PageTools from './PageTools'
export default {
install(Vue) {
Vue.component('PageTools', PageTools)
}
}
2.main.js引入使用
import Components from './components'
Vue.use(Components)
边栏推荐
- 图像处理用什么神经网络,神经网络提取图片特征
- day16--The use of the packet capture tool Charles
- raid5的写性能,是不的比raid10快一些?
- 时序动作定位 | ACGNet:弱监督时序动作定位的动作补充图网络(AAAI 2022)
- 明明加了唯一索引,为什么还是产生重复数据?
- 每日一题,数组字符串的匹配问题
- 机器人控制器编程实践指导书旧版-实践一 LED灯(数字量)
- 每日一题,二叉树中增加一行
- 2022-08-01 网工进阶(二十三) VLAN高级技术-VLAN聚合、MUX VLAN
- Power function Exponential function Logarithmic function
猜你喜欢
随机推荐
明明加了唯一索引,为什么还是产生重复数据?
.NET-7.WPF learning experience summary
SQL SERVER 数据库,表的数据发生增删改,该表的索引会在ldf日志中记录吗?
NPU architecture and force analysis
Go-Excelize API源码阅读(十一)—— GetActiveSheetIndex()
Rust learning: 6.5_Array of composite types
深度剖析“八大排序”(上)_ 探寻一些不为人知的细节
How AliExpress sellers seize product search weight
同步锁synchronized追本溯源
Introduction to C integer data storage
【Rust指南】使用Cargo工具高效创建Rust项目 | 理解Rust特别的输入输出语句
【业务架构】价值链分析:提高客户价值和盈利能力
【搜索引擎】Solr:提高批量索引的性能
VS2013-debug assembly code-generate asm file-structure memory layout-function parameter stack-calling convention
StringUtils的具体操作
uni 小程序腾讯地图polygon背景透明度
js reduce
The implementation of the seemingly useless component (text gradient) in NaiveUI is so simple
Introduction to the C language to realize bubble sort
如何远程调试对方的H5页面