webpack:
require.context()
Vite:
异步:import.meta.glob('./modules/**/*.ts')
同步:const modules = import.meta.glob('./modules/**/*.ts', { eager: true })
注意:import.meta.glob('./modules/**/*.ts') 是异步的,你不能直接同步地在另一个页面中使用这些模块;
require.context()
异步:import.meta.glob('./modules/**/*.ts')
同步:const modules = import.meta.glob('./modules/**/*.ts', { eager: true })
注意:import.meta.glob('./modules/**/*.ts') 是异步的,你不能直接同步地在另一个页面中使用这些模块;