Problems with vue router (history mode) in development server Vue.js - “Cannot GET /config”

纵然是瞬间 提交于 2019-12-19 10:23:17

问题


I just wanted to setup my vue project with the full webpack template, use vue router and link different urls to different components.

The src/router/index.html is the following:

import Vue from 'vue';
import Router from 'vue-router';
// eslint-disable-next-line
import Home from '../pages/home.vue';
// eslint-disable-next-line
import Config from '../pages/config.vue';

Vue.use(Router);

export default new Router({
  mode: 'hash',
  routes: [
    { path: '/', component: Home },
    { path: '/config', component: Config },
  ],
});

When I run npm run dev and access the above routes, I have the following output:

Up to here, everything is working fine. The problem is when I use the history mode, I can’t access to localhost:8080/config:

And the console doesn’t show any error:

Another thing I tried was switching the mode to history using the simple-webpack template. The worst part is that it worked! So, the problem is in the webpack-template, but I don't know how to make this work.

I'll appreciate any help.

来源:https://stackoverflow.com/questions/48068084/problems-with-vue-router-history-mode-in-development-server-vue-js-cannot-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!