1.安装依赖
npm install vue-json-excel
yarn add vue-json-excel
2.页面引入
import JsonExcel from "vue-json-excel";
export default {
components: {
"download-excel": JsonExcel,
},
}
3.组件引用
<download-excel :fields="field" :data="List" name="客户统计表" type="xls">
<el-button size="mini" type="warning">导出数据</el-button>
</download-excel>
4.写入导出数据
data(){
return{
field:{
导出中文名:'数据对应字段名'
},
List:[],//需要导出的数据
}
}
该文章介绍了在Vue应用中如何安装和使用vue-json-excel库来导出数据。首先,通过npm或yarn安装依赖;然后,在页面中引入组件;接着,在组件中引用并设置字段和数据;最后,展示了数据结构和导出的示例。
5535

被折叠的 条评论
为什么被折叠?



