guides/vue-qa.md
2024-01-11 20:00:55 +08:00

639 B

前端开发中的问题整理

  1. 路由引入时,如果是动态引入,要使用方法来引入
import MapView from '@/views/MapView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: MainView
    },
    {
      path: '/mapView',
      name: 'mapView',
      component: MapView, ✅
    },
    {
      path:'/login', 
      name:'login', 
      // component: import('@/views/Login.vue')          ❌   有可能出bug引入文件失败
      component: () => import('@/views/Login.vue')    ✅
    },
  ]
})