v-if使用失效及导出问题

img

大家看看是什么问题,为什么使用v-if会失效,还有什么可行办法,通过判断是否为空,空导出4列,不为空都导出

首先,母号为空按钮不显示,只需要v-if="scope.row.motherCode"。其次,在下载方面,如果你的下载是通过调接口返回流的形式下载的话,这个问题需要后端解决。

下载按钮是在表格之外吧,scope.row是表格每行的数据,你这里要用表格数据判断

<el-button v-if="hasMotherCode"></el-button>
// 一行存在母号就显示下载按钮
let hasMotherCode = false
tableData.some(item => {
  if (item.motherCode) {
    hasMotherCode = true
    return true
  }
})
this.hasMotherCode = true

另外的导出是前端操作的话,也是通过数据来处理

// 筛选出存在母号的数据
let exportData = tableData.filter(item => item.motherCode)
// 导出操作