想让el-card占满layout中剩下的部分,当前是由内容撑开的
给el-card加样式,因为是套了两层,所以是要给其自身和body-style都加上height:100%
一开始想着只是给el-card加body-style就行了 但是加了height:100%之后发现没有用
又试了一下 给它加500px是可以生效的,那就是百分比这种形式无法生效,因为这个东西是两层 父元素的height不是100%,只给 body加100%是没有用的,所以还需要在style中给其本身再加一个height:100%.
<template>
<el-card :body-style="{display:'flex', flexDirection: 'column', height:'100%', position: 'relative',overflow: 'hidden'}">
<div class="btn-wrapper">
<el-button type="primary" size="default" icon="Plus" @click="addTrademark">添加</el-button>
</div>
<el-table style="margin: 10px 0;" border :data="trademarArr" class="card-table" height="100%">
.el-card{
height: 100%;
}
这里给el-button套了一层,否则会因为flex布局而占满宽度。