<template> <app-container> <el-tabs v-model="activeName" type="card" @tab-click="handleClick"> <el-tab-pane label="路灯" name="lamp"> <lamp-type-list ref="lamp"/> </el-tab-pane> <el-tab-pane label="灯箱" name="box"> <lampbox-type-list ref="box"/> </el-tab-pane> </el-tabs> </app-container> </template> <script> import LampTypeList from './lampType/lampTypeList' import LampboxTypeList from './lampboxType/lampboxTypeList' export default { name: 'AlarmRule', components: { LampboxTypeList, LampTypeList }, data() { return { activeName: 'lamp' } }, created() { this.$refs.lamp.fetchData() }, mounted() { this.$refs.lamp.fetchData() }, methods: { handleClick(tab, event) { if (tab.name === 'lamp') { this.activeName = 'lamp' this.$refs.lamp.fetchData() } else if (tab.name === 'box') { this.activeName = 'box' this.$refs.box.fetchData() } } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> $tableTitleHeight:46px; .table{ margin-bottom: 20px; } .pagination-container{ margin-bottom: 50px; } .table-title{ background-color:rgba(243, 243, 243, 1); height: $tableTitleHeight; .title-header{ line-height:$tableTitleHeight; color: #606266; font-size: 15px; i{ margin-left: 5px; margin-right: 5px; } } } .edit_btns{ .edit_btn{ float:right; margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2 } } </style>