// 引入依赖 import Vue from 'vue' import VueRouter from 'vue-router' import autoRouter from "../../static/js/vue-auto"; Vue.use(VueRouter); let routes = autoRouter({ // 页面级的.vue存放位置,必传 rc: require.context("@/views", true, /\.vue$/), // '/'的重定向,可选,默认为'' redirect: "/login", // 页面级的.vue存放的文件夹,可选,默认为:views rootFile: "views" }); const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } // 404 routes.push({ path: "*", redirect: "/state" }); export default new VueRouter({ mode: "history", routes });