Notes on the use of vue-router

When I used vue-router for the first time, I found that the routes array was configured and the configured path was still inaccessible.
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' }
            ]
        }
    },

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326145271&siteId=291194637