在Vue 3项目中安装和使用 js-table2excel
可以通过以下步骤进行:
-
首先,确保你的项目是基于Vue 3创建的。
-
使用npm或者yarn安装
js-table2excel
库:
安装一下npm install js-table2excel
# 或者
yarn add js-table2excel、
const Value_Data=[{ title:'某人' }] const fun=()=>{ const column = [ //数据表单 { title: "序号", //表头名称title key: "id", //数据 type: "text", //类型 }, { title: "用户姓名", key: "name", type: "text", }, { title: "用户昵称", key: "nickname", type: "text", }, { title: "用户头像", key: "imgs", type: 'image', width: 80, height: 80, }, { title: "手机号", key: "tel", type: "text", width: 130, height: 80, }, { title: "商品名称", key: "ticketName", type: "text", width: 130, height: 80, }, { title: "商品状态", key: 'sheng', type: "text", width: 130, height: 80, } , { title: "支付状态", key: "shen", type: "text", width: 130, height: 80, }, { title: "订单号", key: "orderNum", type: "text", width: 130, height: 80, }, { title: "支付金额", key: "money", type: "text", width: 130, height: 80, }, { title: "商品价格", key: "ticketPrice", type: "text", width: 130, height: 80, }, { title: "支付日期", key: "pay_time", type: "text", width: 130, height: 80, }, { title: "过期日期", key: "over_time", type: "text", width: 130, height: 80, }, { title: "下单日期", key: "create_time", type: "text", width: 130, height: 80, }, ]; let tableDatas = JSON.stringify(Value_Data.value); let datas = tableDatas; table2excel(column, datas, "订单导出"); //表单数据名称 }