vite不支持require.context的方引入文件,需要使用import.meta.glob
import { defineAsyncComponent } from 'vue'
const components = import.meta.glob('../components/*.vue')
for (const [key, value] of Object.entries(components)) {
const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'))
app.component(name, defineAsyncComponent(value))
}