路由懒加载,还是压缩打包的js文件

This commit is contained in:
xing 2020-07-02 11:12:56 +08:00
parent c526ea7d4e
commit 64aedb7466
4 changed files with 44 additions and 15 deletions

View File

@ -1,5 +1,8 @@
module.exports = { module.exports = {
presets: [ presets: [
'@vue/cli-plugin-babel/preset' '@vue/cli-plugin-babel/preset'
],
plugins: [
'@babel/plugin-syntax-dynamic-import'
] ]
} }

View File

@ -20,6 +20,7 @@
"vue-table-with-tree-grid": "^0.2.4" "vue-table-with-tree-grid": "^0.2.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@vue/cli-plugin-babel": "~4.4.0", "@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-plugin-eslint": "~4.4.0", "@vue/cli-plugin-eslint": "~4.4.0",
"@vue/cli-plugin-router": "~4.4.0", "@vue/cli-plugin-router": "~4.4.0",

View File

@ -1,23 +1,41 @@
import Vue from 'vue' import Vue from 'vue'
import VueRouter from 'vue-router' import VueRouter from 'vue-router'
import Login from '../components/Login'
import Home from '../components/Home' // import Login from '../components/Login'
import welcome from '../components/welcome' const Login = () => import(/* webpackChunkName: "login-home-welcome" */ '../components/Login')
import users from '../components/users/users'
import access from '../components/access/access' // import Home from '../components/Home'
import roles from '../components/access/roles' const Home = () => import(/* webpackChunkName: "login-home-welcome" */ '../components/Home')
import categories from '../components/goods/categories'
import params from '../components/goods/params' // import welcome from '../components/welcome'
import goods from '../components/goods/goods' const welcome = () => import(/* webpackChunkName: "login-home-welcome" */ '../components/welcome')
import goodsEdit from '../components/goods/edit'
import order from '../components/order/order' // import users from '../components/users/users'
import report from '../components/report/report' // import access from '../components/access/access'
// import roles from '../components/access/roles'
const users = () => import(/* webpackChunkName: "login-home-users" */ '../components/welcome')
const access = () => import(/* webpackChunkName: "login-home-users" */ '../components/access/access')
const roles = () => import(/* webpackChunkName: "login-home-users" */ '../components/access/roles')
// import categories from '../components/goods/categories'
// import params from '../components/goods/params'
// import goods from '../components/goods/goods'
// import goodsEdit from '../components/goods/edit'
const categories = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/categories')
const params = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/params')
const goods = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/goods')
const goodsEdit = () => import(/* webpackChunkName: "login-home-goods" */ '../components/goods/edit')
// import order from '../components/order/order'
// import report from '../components/report/report'
const order = () => import(/* webpackChunkName: "login-home-order" */ '../components/order/order')
const report = () => import(/* webpackChunkName: "login-home-order" */ '../components/report/report')
Vue.use(VueRouter) Vue.use(VueRouter)
const routes = [ const routes = [
{ path: '/', redirect: '/login' }, {path: '/', redirect: '/login'},
{ path: '/login', component: Login }, {path: '/login', component: Login},
{ {
path: '/home', path: '/home',
component: Home, component: Home,

View File

@ -377,13 +377,20 @@
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.10.1" "@babel/helper-plugin-utils" "^7.10.1"
"@babel/plugin-syntax-dynamic-import@^7.8.0", "@babel/plugin-syntax-dynamic-import@^7.8.3": "@babel/plugin-syntax-dynamic-import@^7.8.0":
version "7.8.3" version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3"
integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ== integrity sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.8.0" "@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-dynamic-import@^7.8.3":
version "7.8.3"
resolved "https://registry.npm.taobao.org/@babel/plugin-syntax-dynamic-import/download/@babel/plugin-syntax-dynamic-import-7.8.3.tgz?cache=0&sync_timestamp=1578950368021&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fplugin-syntax-dynamic-import%2Fdownload%2F%40babel%2Fplugin-syntax-dynamic-import-7.8.3.tgz#62bf98b2da3cd21d626154fc96ee5b3cb68eacb3"
integrity sha1-Yr+Ysto80h1iYVT8lu5bPLaOrLM=
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-json-strings@^7.8.0": "@babel/plugin-syntax-json-strings@^7.8.0":
version "7.8.3" version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a"