Browse Source

1.路由改为histroy模式,懒加载
2.vue.config.js 打包路径 修改
3.gitignore文件 忽略提交打包后的wandaEditer目录

unknown 4 years ago
parent
commit
d4b2f69c11
3 changed files with 18 additions and 6 deletions
  1. 1 0
      .gitignore
  2. 12 6
      src/router/index.ts
  3. 5 0
      vue.config.js

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 .DS_Store
 node_modules
 /dist
+/wandaEditer
 package-lock.json
 
 # local env files

+ 12 - 6
src/router/index.ts

@@ -1,23 +1,29 @@
 import Vue from 'vue'
 import VueRouter, { RouteConfig } from 'vue-router'
-import editer from '../views/editer.vue'
-import drafts from '../views/drafts.vue'
+const Editer = () => import('../views/editer.vue')
+const Drafts = () => import('../views/drafts.vue')
 Vue.use(VueRouter)
 
-  const routes: Array<RouteConfig> = [
+const routes: Array<RouteConfig> = [
   {
     path: '/',
+    redirect: '/editer'
+  },
+  {
+    path: '/editer',
     name: 'editer',
-    component: editer
+    component: Editer
   },
   {
     path: '/drafts',
     name: 'drafts',
-    component: drafts
+    component: Drafts
   }
 ]
-
+// 使用histroy模式
 const router = new VueRouter({
+  mode: 'history',
+  base: process.env.BASE_URL,
   routes
 })
 

+ 5 - 0
vue.config.js

@@ -36,4 +36,9 @@ module.exports = {
     },
     lintOnSave: false,
     // publicPath: '/dist',
+    publicPath: '/wandaEditer',
+    // 打包名称
+    outputDir: 'wandaEditer',
+    // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
+    assetsDir: "static",
 }