技術堆疊:vue3
問題:打包放到服務器上后通過nginx無法正常訪問,控制臺報vue-router相關錯誤
問題代碼:
const routes = [
{
path: '/',
component: () => require('../views/Main')
},
...
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
修改為:
const routes = [
{
path: '/',
component: () => import('../views/Main')
},
...
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
或者:
import Main from '../views/Main'
const routes = [
{
path: '/',
component: Main
},
...
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
問題解決,瀏覽器可以正常訪問
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/290221.html
標籤:其他
上一篇:小白式部署前端頁面
下一篇:Nginx總結
