Vue3 打包通过相对路径访问空白的解决办法
参考
步骤
- /vue.config.js 配置打包路径,因为是相对路径访问,所以配置 publicPath 为空或 “./”
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
// 修改端口号:https://blog.csdn.net/qq_39313596/article/details/83544745
devServer:{
port: 8081
},
// https://cli.vuejs.org/zh/config/#publicpath
publicPath: ""
})
- /src/router/index.ts 将默认路由类型 createWebHistory 改为 createWebHashHistory 路由
import { createRouter, createWebHistory, RouteRecordRaw,createWebHashHistory } from 'vue-router';
const router = createRouter({
// history: createWebHistory(process.env.BASE_URL),
history: createWebHashHistory(process.env.BASE_URL),
routes
});
博 主 :夏秋初
地 址 :https://www.cnblogs.com/xiaqiuchu/p/16030320.html
如果对你有帮助,可以点一下 推荐 或者 关注 吗?会让我的分享变得更有动力~
转载时请带上原文链接,谢谢。
地 址 :https://www.cnblogs.com/xiaqiuchu/p/16030320.html
如果对你有帮助,可以点一下 推荐 或者 关注 吗?会让我的分享变得更有动力~
转载时请带上原文链接,谢谢。

浙公网安备 33010602011771号