前后端知识库 前后端知识库
首页
    • JavaScript
    • React
    • Vue
  • Python
  • Sanic
  • Linux
  • Ansible
归档
GitHub (opens new window)
首页
    • JavaScript
    • React
    • Vue
  • Python
  • Sanic
  • Linux
  • Ansible
归档
GitHub (opens new window)
  • JavaScript

  • React

  • Vue

    • 基础

    • 组件

    • 过渡&动画

    • 可复用性&组合

    • 工具

    • 规模化

      • vuex操作相关
      • 路由懒加载
    • 其他

  • frontend
  • Vue
  • 规模化
devin
2023-09-07

路由懒加载

# 路由懒加载

// 路由同步加载
// import Recommend from '@/components/recommend/recommend'
// import Singer from '@/components/singer/singer'
// import Rank from '@/components/rank/rank'
// import Search from '@/components/search/search'
// import SingerDetail from '@/components/singer-detail/singer-detail'
// import Disc from '@/components/disc/disc'
// import TopList from '@/components/top-list/top-list'
// import UserCenter from '@/components/user-center/user-center'

Vue.use(Router);

// 路由懒加载
const Recommend = () => import("@/components/recommend/recommend");
const Singer = () => import("@/components/singer/singer");
const Rank = () => import("@/components/rank/rank");
const Search = () => import("@/components/search/search");
const SingerDetail = () => import("@/components/singer-detail/singer-detail");
const Disc = () => import("@/components/disc/disc");
const TopList = () => import("@/components/top-list/top-list");
const UserCenter = () => import("@/components/user-center/user-center");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

使用路由懒加载可使 app.js 文件变小,进入不同路由在分别加载该路由的 js。

编辑 (opens new window)
上次更新: 2023/09/07, 15:09:00
vuex操作相关
Vue中的防抖函数封装和使用

← vuex操作相关 Vue中的防抖函数封装和使用→

Theme by Vdoing | Copyright © 2023-2023 devin | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式