接口参数拼接在url后面

   async exportData () {

      let data = {

        current: this.pagination.current,

        size: this.pagination.pageSize,

        ...this.searchForm

      }

      let res = []

      let ret = ''

      for (const key in data) {

        if (data[key]) {

          res.push(`${key}=${data[key]}`)

        }

      }

      if (Object.keys(data).length > 1) {

        ret = '?' + res.join('&')

      } else {

        ret = `?${res[0]}`

      }

      // console.log('ret', ret);

      let url = window.location.origin +

        process.env.VUE_APP_BASE_API + `/market/sgmCustormer/download/exportData${ret}`

      console.log(url)

      window.open(url)

    },

你可能感兴趣的:(接口参数拼接在url后面)