feat(play): file doesn't exist jump to App (#5985)

* feat(play): file doesn't exist jump tp App

* chore: update
This commit is contained in:
btea 2022-02-11 10:32:03 -06:00 committed by GitHub
parent b825c07865
commit 3a4f2177ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,12 @@ import '@element-plus/theme-chalk/src/index.scss'
;(async () => { ;(async () => {
const apps = import.meta.glob('./src/*.vue') const apps = import.meta.glob('./src/*.vue')
const name = location.pathname.replace(/^\//, '') || 'App' const name = location.pathname.replace(/^\//, '') || 'App'
const App = (await apps[`./src/${name}.vue`]()).default const file = apps[`./src/${name}.vue`]
if (!file) {
location.pathname = 'App'
return
}
const App = (await file()).default
const app = createApp(App) const app = createApp(App)
app.mount('#play') app.mount('#play')