vue中表格的导出与文件的导入功能

1、导出文件

     export({
        tableId: selectId
      })
        .then(res => {
          let url = window.URL.createObjectURL(new Blob([res.data.data]))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          // 获取文件名
          // download 属性定义了下载链接的地址而不是跳转路径
          link.setAttribute('download', 'aaa')
          console.log(res)
          document.body.appendChild(link)
          link.click()
        })

2、导入文件

importFile(form).then(res => {
    if (res.data.code === 200) {
          this.formData = res.data.data
        }
     })

你可能感兴趣的:(vue中表格的导出与文件的导入功能)