import.meta.globEage导入文件时无法通过files[key].default拿到内容,因为files对象得value是一个函数,需要调用这个函数,它返回一个promise,在then回调中才能拿到,代码如下:
const files = import.meta.globEage('./../../assets/tree-icon/*.png');
for (const key in files) {
if (Object.prototype.hasOwnProperty.call(files, key)) {
files[key]().then((resp) => {
console.log(resp.default)
})
}
}