Explorar o código

feat(nuxt.config.js):404路由重定向到首页

liyangbin %!s(int64=2) %!d(string=hai) anos
pai
achega
00df901993
Modificáronse 1 ficheiros con 11 adicións e 1 borrados
  1. 11 1
      nuxt.config.js

+ 11 - 1
nuxt.config.js

@@ -67,5 +67,15 @@ export default {
   build: {
     vendor: ['element-ui']
   },
-  loading: false
+  loading: false,
+  //用户输入不存在的路径,跳到首页
+  router: {
+    extendRoutes(routes, resolve) {
+      routes.push({
+        path: '*',
+        redirect: '/'
+      })
+    }
+  }
+
 }