> 使用blob流下載Excel文檔
```
this.$api.exportData(this,'admin/u/p/order/grow/rate/export',{
createTime:this.createTime,
content: this.content}).then(res =>{
const content = res
let blob = new Blob([content],{
type: "application/ms-excel"
})
let url = window.URL.createObjectURL(blob)
if ('download' in document.createElement('a')) {
let link = document.createElement('a')
link.style.display ='none'
link.href = url
link.setAttribute('download','訂單增長率.xls')
document.body.appendChild(link)
link.click()
}else{
navigator.msSaveBlob(blob, 'excel.xls')
}
})
},
```
*****
```
exportDownload() { //..導出訂單折扣明細表
this.loading = true
this.timeData.push(this.formData.time\[0\]) //..開始時間
this.timeData.push(this.formData.time\[1\]+ 24\*60\*60\*1000) //..結束時間選擇當天加上一天
this.$api.exportData(this,'admin/u/p/order/orderDiscountDownLoad',{
type: this.formData.type, //..訂單類型
time: this.timeData, //..訂單時間
businessUnitId: this.formData.businessUnitId, //..事業部ID
itemCode: this.formData.itemCode, //..貨品編碼
status: this.formData.status //..訂單狀態
}).then(res =>{
this.loading = false
if(res.code == undefined) {
<!-- 請求成功后的操作 -->
this.timeData = [] //..成功下載Excel后初始化選中時間
this.formData.status = [] //..成功夏侯Excel后初始化訂單狀態
}
const content = res
let blob = new Blob(\[content\],{
type: "application/ms-excel"
})
let url = window.URL.createObjectURL(blob)
if ('download' in document.createElement('a')) {
let link = document.createElement('a')
link.style.display ='none'
link.href = url
link.setAttribute('download','訂單折扣明細表.xls')
document.body.appendChild(link)
link.click()
}else{
navigator.msSaveBlob(blob, '訂單折扣明細表.xls')
}
})
},
```
- 前言
- 寫在前言
- 一些開發遇到的問題
- H5標簽中的屬性控制
- el-table的每個對象的屬性值
- el-form多個表單同時驗證必填項
- el-table 修改表頭
- el-input的多種驗證
- vue鍵盤回車事件
- blob導出
- table中selectable( 是否勾選)
- 手動更新視圖
- 日期選擇器,自定義可選范圍
- select 自定義搜索
- 監聽回車事件
- 表格初始化不可勾選
- el-input輸入限制
- table時間格式轉換
- table自適應高度
- JS問題記錄
- js字符數組轉換為數字數組
- js防抖和節流
- JS電腦是否有網判斷
- JS屬性記錄
- 遍歷方法(12個)
- 改變原數組(9個)
- 不改變原數組(8個)
- JS數組、字符串常用方法
- 遍歷對象
- Vue
- vue-router
- vue-router 如何在新窗口打開頁面
- vue-router 之 keep-alive緩存篇
- keep-alive項目案例
- 路由知識點歸納總結
- params、query傳參
- vue問題記錄
- vuejs npm chromedriver 報錯
- vuex
- vuex個人理解
- Vuex的簡單實例應用