中等Vue路由
0 1

Vue Router的懒加载如何实现?

【概念释义】

路由懒加载将页面组件拆成独立异步 chunk,访问路由时才 import(),降低首屏 JS 体积。Vue Router 通过将 component 设为返回 Promise 的函数实现,与 Vite/Webpack 动态 import 天然配合。

【基础使用】

javascript
const routes = [
  {
    path: '/dashboard',
    component: () => import('@/views/Dashboard.vue'),
  },
  {
    path: '/report',
    name: 'Report',

登录查看完整 1341

回答讨论

暂无讨论,登录后可抢先发言

本题库更多题目(50)