test.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <download-excel class="export-excel-wrapper" :data="json_data" :fields="json_fields" footer='页脚' header='导出数据'
  3. name="设备管理数据表.xls">
  4. <!-- 上面可以自定义自己的样式,还可以引用其他组件button -->
  5. <button type="primary" size="small">导出EXCEL</button>
  6. </download-excel>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. json_fields: {
  13. "单位编号": "company", //常规字段
  14. "状态": "device_state",
  15. "设备编号": "owner_code",
  16. "设备名称": "owner_name",
  17. "单元地址": "unitinfo",
  18. "创建时间": "install_time",
  19. },
  20. json_data: [{
  21. name: "Tony Peña",
  22. city: "New York",
  23. country: "United States",
  24. birthdate: "1978-03-15",
  25. phone: {
  26. mobile: "1-541-754-3010",
  27. landline: "(541) 754-3010"
  28. }
  29. },
  30. {
  31. name: "Thessaloniki",
  32. city: "Athens",
  33. country: "Greece",
  34. birthdate: "1987-11-23",
  35. phone: {
  36. mobile: "+1 855 275 5071",
  37. landline: "(2741) 2621-244"
  38. }
  39. }
  40. ],
  41. json_meta: [
  42. [{
  43. " key ": " charset ",
  44. " value ": " utf- 8 "
  45. }]
  46. ]
  47. };
  48. }
  49. }
  50. </script>