一个简单的小开发
首页
分类
标签
归档
关于

YDS

30岁大龄程java程序员,心不老,神不灭
首页
分类
标签
归档
关于
  • vue项目设置-vscode
  • 在github的pages上部署一个vue3的项目
  • vue3部署githubpages问题汇总
    • 问题
      • plugin-vueexport-helper.js找不到,提示404
      • 页面不能正确的打开
  • 鸿蒙app开发中的数据驱动ui渲染问题
  • JS
yds
2024-06-19
目录

vue3部署githubpages问题汇总

# 问题

# _plugin-vue_export-helper.js找不到,提示404

修改vite.config.ts,在build.rollupOptions里这样写

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// eslint-disable-next-line no-control-regex
const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
const DRIVE_LETTER_REGEX = /^[a-z]:/i;

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  build: {
    rollupOptions: {
      output: {
        sanitizeFileName(name) {
          const match = DRIVE_LETTER_REGEX.exec(name);
          const driveLetter = match ? match[0] : '';
          return (
            driveLetter +
            name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, "")
          );
        },
      },
    },
  },
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

# 页面不能正确的打开

因为使用github pages时,url上需要加上仓库名,所以需要在项目里做下修改,在vite.config.ts中设置base字段

export default defineConfig({
  ## 项目名,和仓库名保持一致
  base: '/common-admin/',
})
1
2
3
4

修改router,和base保持一致

const router = createRouter({
    history: createWebHistory("/common-admin/"),
    routes: staticRoutes,
    
});
1
2
3
4
5

如果使用了axios来mock接口数据,也需要处理下baseurl

项目代码在这里 (opens new window)

#VUE#GITHUB
上次更新: 2024/09/30, 01:34:11
在github的pages上部署一个vue3的项目
鸿蒙app开发中的数据驱动ui渲染问题

← 在github的pages上部署一个vue3的项目 鸿蒙app开发中的数据驱动ui渲染问题→

最近更新
01
使用docker-compose安装mysql
09-30
02
鸿蒙app开发中的数据驱动ui渲染问题
08-01
03
LINUX连接openvpn
07-02
更多文章>
Theme by Vdoing | Copyright © 2020-2024 YDS
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式