Connot GET /XXXX will appear when accessing
import View from 'view'; import Router from 'vue-router'; import Home from 'src@/views/Home.vue' import FlightList from 'src@/views/FlightList.vue' Vue.use(Router) export default new Router({ mode: 'history', base: '/', routes: [ { path: '/', name: 'Home', component: Home }, { path: '/index', component: Home }, { path: '/flight-list', name: 'flightList', component: FlightList } ] })
After google, it was found that when vue-route uses history mode, it needs server backend support, that is, the backend needs to return an html address for the corresponding request address. Therefore, one should be configured in webpack.dev.config.js for the local service devServer:
devServer: contentBase: './dist', hot: true, historyApiFallback: { rewrites: [ { from: /^\*$/, to: '/dist/index.html' } ] } },