1. VUE中使用vue-json-excel超級方便導出excel表格數據
一、安裝vue-json-excel
npm install vue-json-excel -S
二、main.js裡面引入並注冊使用
import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel)
三、頁面中使用
<download-excel
class = "export-excel-wrapper"
:data = "json_data"
:fields = "json_fields"
name = "filename.xls">
<!-- 上面可以自定義自己的樣式,還可以引用其他組件button -->
<!-- <el-button type="primary" size="small">導出EXCEL</el-button> -->
</download-excel>
在這里說明一下組件的各個屬性
json_data:需要導出的數據
json_fields:自主選擇要導出的欄位,若不指定,默認導出全部數據中心全部欄位
2. vue.js鍵盤操作表格選中那一行
computed計算屬性,你值得擁有
或者,寫點擊事件,篩選出所有的選中的行數據,第二張圖渲染總數就可以了