iview expertCsv 不可用

   leadingOut () {
        if (this.choosed.length === 0) {
          alert('请至少勾选一项');
        } else {
          this.$refs.table.exportCsv({
            filename: '自定义数据',
            columns: this.tableColumns.filter((col, index) => index < 4),
            data: this.tableData.filter((data, index) => index < 4)
          });
  }

报错信息

index.vue?7346:354 Uncaught TypeError: Cannot read property 'exportCsv' of undefined

at VueComponent.leadingOut (eval at 641 (0.4bb8438….hot-update.js:7), <anonymous>:235:25)
at boundFn (eval at <anonymous> (app.js:759), <anonymous>:170:14)
at VueComponent.invoker (eval at <anonymous> (app.js:759), <anonymous>:1743:18)
at VueComponent.Vue.$emit (eval at <anonymous> (app.js:759), <anonymous>:2210:16)
at VueComponent.handleClick (eval at <anonymous> (app.js:4773), <anonymous>:7344:18)
at boundFn (eval at <anonymous> (app.js:759), <anonymous>:170:14)
at HTMLButtonElement.invoker (eval at <anonymous> (app.js:759), <anonymous>:1743:18)

table没有获取到 $refs为空对象

阅读 6.1k
2 个回答

看官方示例,添加参数<Table …ref=table>

新手上路,请多包涵

如果有分页的话,怎么能将全部数据导出而不仅仅是当前页面的数据呢?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏