[electron + vue] build 결과물에서 router 작동하지 않는 문제 수정

jong·2022년 10월 8일
0

Node & JavaScript

목록 보기
9/9

electron을 개발하면서 디버깅할 때는 router가 문제없이 작동하였는데, 이상하게 build만 하면 프로그램이 작동을 멈추었다.

이상하다 싶어서 보니 헤더 부분은 잘 나오는데 router 영역만 잘 나오지 않는다.

이에 대한 내용이 https://xshine.tistory.com/345 이 블로그에 잘 정리되어 있다.

index.js

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

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
  },
];

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

export default router;

historycreateWebHashHistory() 메서드로 지정해 주면 된다.

profile
공부 기록

0개의 댓글