vue导出数据
<el-button @click="download" >下载表格</el-button>
download(){
const axios = require("axios");
var datas = sessionStorage.getItem("data");
axios
.post("http://192.168.2.239/api_jsonrpc.php", {
jsonrpc: "2.0",
method: "host.get",
params: {
output: ["hostid", "host"],
// limit:this.rows,
// page:this.page,
// parmas:page,
selectInterfaces: ["interfaceid", "ip"],
},
id: 2,
auth: datas,
})
.then(res => {
let url=window.URL.createObjectURL(new Blob([res]))
let link =document.createElement("a")
link.style.display="none"
link.href=url
link.setAttribute('download',"数据中心.xls")
document.body.appendChild(link)
link.click()
})
.catch(function (error) {
console.log(error);
});
}