vue, download the export file, open a new window to export

vue, download the export file, open a new window to export

Encapsulate the method of setting url parameters

//设置url参数
//setUrlPrmt({'a':1,'b':2})
//显示 a=1&b=2
setUrlPrmt(obj) {
  let _rs = [];
  for (let p in obj) {
    if (obj[p] != null && obj[p] != '') {
      _rs.push(p + '=' + obj[p])
    }
  }
  return _rs.join('&');
}

Introduce BaseUrl, use template strings to splice request paths and carry parameters

let str = setUrlPrmt(data);//需要导出的列表是一个对象格式
window.open(`${BaseUrl}/UserManager/exportUserListExcel?${str}`);

Guess you like

Origin blog.csdn.net/weixin_44221744/article/details/112463996