
如果你習慣于vue ui的 話 可以直接搜索依賴安裝
npm install vue-json-excel -S
在main.js中使用
import JsonExcel from 'vue-json-excel'
Vue.component('downloadExcel', JsonExcel)
看使用方法就知道這是注冊了一個全局組件,我們只需要傳入相應的屬性即可了
<downloadExcel
:data="json_data"
:fields="json_fields"
header="表格標題"
name="需要導出的表格名稱.xls"
>
<el-button type="primary" size="small">導出EXCEL</el-button>
</downloadExcel>
給大家復制 方便測試
json_data: [
{
Name: "張三",
China: "90",
Math: "93",
English: "88"
},
{
Name: "李四",
China: "94",
Math: "92",
English: "86"
}
],
json_fields: {
姓名: "Name",
語文: "China",
數(shù)學: "Math",
英語: "English"
},
