<el-tabs v-model="activeName" @tab-click="handleClick" type="border-card"> <el-tab-pane label="报表" name="first"> <myTable :columns="columns" :dataSource="dataSource" :hasIndex="false" :hasSelection="false" :hasPagination="true" v-loading="loading"> </myTable> </el-tab-pane> <!-- 报表 end --> <el-tab-pane label="图表" name="second" :key='activeName'> <el-row> <el-col :span="8"><div> <ve-histogram :data="chartData" v-if="key='activeName'"></ve-histogram></div></el-col> </el-row> </el-tab-pane> <!-- 柱状图表 end -->
只要加上上面下划线部分代码即可,利用了v-if重新渲染的特性。
方法二: