当前位置:网站首页>封装和使用通用的工具栏组件
封装和使用通用的工具栏组件
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)边栏推荐
猜你喜欢

ABAP Data Types 和XSD Type 映射关系以及XSD Type属性

90.(cesium之家)cesium高度监听事件

一文2600字手把手教你编写性能测试用例

时序动作定位 | ACGNet:弱监督时序动作定位的动作补充图网络(AAAI 2022)

2022-08-01 Advanced Network Engineering (23) Advanced VLAN Technology - VLAN Aggregation, MUX VLAN

自动化测试框架Pytest(三)——自定义allure测试报告

34. Talk about why you want to split the database?What methods are there?

【FAQ】【Push Kit】推送服务,回执配置一直报错、回执过期修改、怎么删除配置的回执

二叉树 --- 堆

DGIOT supports industrial equipment rental and remote control
随机推荐
自动化测试框架Pytest(一)——入门
自动化测试框架Pytest(三)——自定义allure测试报告
详解构建mock服务最方便的神器——Moco
NPU architecture and force analysis
高性能短连接设计
CV+Deep Learning - network architecture Pytorch recurrence series - classification (3: MobileNet, ShuffleNet)
Introduction to the delta method
DGIOT supports industrial equipment rental and remote control
Uni-app开发微信小程序使用本地图片做背景图
【转】探秘钉钉的即时消息服务DTIM
【Unity入门计划】Collision2D类&Collider2D类
协同工具满足70%-90%的工作需求,成为企业香饽饽
大体来讲,网站会被攻击分为几种原因
快速输入当前日期与时间
Go-Excelize API source code reading (11) - GetActiveSheetIndex()
明明加了唯一索引,为什么还是产生重复数据?
The sixteenth day & the basic operation of charles
foreach遍历删除元素问题总结
【业务架构】价值链分析:提高客户价值和盈利能力
In the SQL SERVER database, if the data of the table is added, deleted, or modified, will the index of the table be recorded in the ldf log?