31 lines
639 B
Markdown
31 lines
639 B
Markdown
# 前端开发中的问题整理
|
|
|
|
|
|
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') ✅
|
|
},
|
|
]
|
|
})
|
|
```
|
|
|