Vue Router 的 history 模式与 hash 模式区别?路由懒加载怎么做?

const routes = [
  { path: '/about', component: () => import('./About.vue') }  // 懒加载
]

路由懒加载用动态 import(),配合 Webpack/Vite 自动拆分成独立 chunk,首屏只加载当前路由代码,大幅减小主包。

同分类其他题目