Open czkm opened 1 month ago
vue版本:如vue@3 打包工具及版本:如 "vite": "^4.2.1",
"@vue-office/docx": "^1.6.0", "@vue-office/excel": "^1.7.3", "@vue-office/pdf": "^2.0.0", 打包后报错
ReferenceError: Cannot access 'C9' before initialization at @vue-office-ade5967a.js:1:937 at @vue-office-ade5967a.js:1:945 at @vue-office-ade5967a.js:195:4463
vite配置如下
import { defineConfig, loadEnv } from 'vite' // 使用 defineConfig 工具函数获取类型提示: import { resolve } from 'path'; import vue from '@vitejs/plugin-vue' const pathResolve = (dir) => { return resolve(__dirname, '.', dir); }; const viteConfig = defineConfig((mode) => { const env = loadEnv(mode.mode, process.cwd()); return { optimizeDeps: { force: true // 强制进行依赖预构建 }, resolve: { alias: { '/@': pathResolve('./src/'), '@util': pathResolve('./src/utils/'), '@hook': pathResolve('./src/hook/') }, extensions: ['.js', '.ts', '.json'] // 导入时想要省略的扩展名列表 }, server: { host: env.VITE_IP, port: env.VITE_PORT, open: JSON.parse(env.VITE_OPEN), hmr: true, proxy: { '/api': { // target: `https://${env.VITE_IP}:3000/`, // target: `https://172.31.0.19:5241`, // target: `https://172.31.0.48:5241`, // target: `https://172.31.0.125:5241`, target: `https://192.168.1.65:5241/`,// 服务器地址 changeOrigin: true, secure: false, rewrite: (path) => path.replace(/^\/api/, ''), // rewrite: (path) => path }, }, }, build: { outDir: 'build', // 打包文件的输出目录 assetsDir: 'static', // 静态资源的存放目录 assetsInlineLimit: 4096 // 图片转 base64 编码的阈值 }, plugins: [ vue(), ], define: { __NEXT_VERSION__: JSON.stringify(process.env.npm_package_version), __NEXT_NAME__: JSON.stringify(process.env.npm_package_name), }, } }) export default viteConfig;
换纯js方式预览看看,见说明文档
vue版本:如vue@3 打包工具及版本:如 "vite": "^4.2.1",
"@vue-office/docx": "^1.6.0", "@vue-office/excel": "^1.7.3", "@vue-office/pdf": "^2.0.0", 打包后报错