0
点赞
收藏
分享

微信扫一扫

lighttpd以及socket和WebSocket编程

九点韶留学 2023-09-16 阅读 40

使用electron + vue3 + ts技术栈,开发桌面应用,打包后安装打开是白屏,开发环境却没事

解决方案:很大可能是路由问题,把history模式改为hash模式:
将createWebHistory改为createWebHashHistory

原代码

import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import HomeView from "../views/Home/HomeView.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "home",
    component: HomeView
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;

改为Hash模式:

import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import HomeView from "../views/Home/HomeView.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "home",
    component: HomeView
  },
];

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes,
});

export default router;

这样可以啦,再次打包安装后打开后一切正常!

举报

相关推荐

0 条评论