请选择 进入手机版 | 继续访问电脑版

清风丶琉璃

注册会员

16

主题

31

帖子

107

积分

注册会员

积分
107
清风丶琉璃
注册会员   /  发表于:2026-1-6 09:02  /   查看:52  /  回复:1
1金币
本帖最后由 Matthew.Xue 于 2026-1-16 16:10 编辑

  1. readFile() {
  2.         let filePath
  3.         if (this.queryParam.type == 2) {
  4.           filePath = '/templates/宏观成本计算对象报表模板两侧LC.xlsx' // 请替换为实际的另一张表文件名
  5.         } else if (this.queryParam.type == 3) {
  6.           filePath = '/templates/宏观成本计算对象报表模板雁宝公司LC.xlsx'
  7.         } else {
  8.           filePath = '/templates/宏观成本计算对象报表模板LC.xlsx'
  9.         }
  10.         console.log(filePath, 'filePath')
  11.         // 宏观成本计算对象报表模板雁宝公司LC
  12.         fetch(filePath)
  13.           .then((response) => {
  14.             return response.blob()
  15.           })
  16.           .then((data) => {
  17.             this.readWithFromJson(data, this.spread)
  18.           })
  19.           .catch((error) => {
  20.             console.log('读取文件失败', error)
  21.           })
  22.       },
  23.       readWithFromJson(data, spread) {
  24.         const file = new File([data], 'temp.xlsx', {
  25.           type:
  26.             'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  27.         })
  28.         const reader = new FileReader()
  29.         reader.onload = (e) => {
  30.           var io = new ExcelIO.IO()
  31.           io.open(
  32.             e.target.result,
  33.             (json) => {
  34.               // 在 fromJSON 完成后执行
  35.               spread.fromJSON(json)
  36.               const sheet = spread.getActiveSheet() // 获取当前工作表
  37.               // sheet.setValue(0, 2, `${this.peiZhi.budgetYear}年经营情况预算表`) // 设置单位名称
  38.               console.log(sheet, 'sheet')
  39.               spread.options.scrollbarMaxAlign = true
  40.               spread.options.tabStripVisible = false
  41.               const products = this.getProducts(
  42.                 this.dataSource[0].macroCostReportDetailsList.length,
  43.               ) // 假设 getProducts 是你的数据方法
  44.               const dataArray = products.map((item) => Object.values(item))
  45.               sheet.setArray(3, 3, dataArray)
  46.               //   // 7. 调整列宽
  47.               sheet.setColumnWidth(0, 120)
  48.               sheet.setRowHeight(0, 60)
  49.               sheet.setColumnWidth(0, 120)
  50.               sheet.setColumnWidth(20, 500)
  51.               console.log(this.columnCount, 'this.columnCount')
  52.               for (let i = 2; i < this.columnCount - 1; i++) {
  53.                 sheet.setColumnWidth(i, 180)
  54.               }
  55.             },
  56.             (error) => {
  57.               console.log('导入失败', error)
  58.             },
  59.           )
  60.         }
  61.         reader.readAsArrayBuffer(file)
  62.       }
复制代码



我npm run build打包以后,部署在系统上报错404未找到,

但是dist里有这个文件他这个要怎么设置?

附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

您好,这个应该是属于vue打包后,根目录发生变化导致的吧,您可以查看一下打包的config文件,以下是ai的回复,您可以参考一下: 提问:vue2在打包部署后,静态文件访问不到了,我应该怎么做?请做出简短的回答 1. 检查并配置 vue.config.js 2. 检查路由模式 history模式:需要服务器配置重定向 hash模式:直接使用 ./作为 publicPath

1 个回复

最佳答案
最佳答案
Matthew.Xue
超级版主   /  发表于:2026-1-6 09:02:15
来自 2#
您好,这个应该是属于vue打包后,根目录发生变化导致的吧,您可以查看一下打包的config文件,以下是ai的回复,您可以参考一下:

提问:vue2在打包部署后,静态文件访问不到了,我应该怎么做?请做出简短的回答

1. 检查并配置 vue.config.js
  1. module.exports = {
  2.   publicPath: process.env.NODE_ENV === 'production'
  3.     ? './'  // 或你的子路径,如 '/my-project/'
  4.     : '/',
  5.   assetsDir: 'static', // 静态资源目录
  6.   indexPath: 'index.html'
  7. }
复制代码
2. 检查路由模式
history模式:需要服务器配置重定向
hash模式:直接使用 ./作为 publicPath
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部