admin管理员组文章数量:1395352
I am retrieving a set of images from a folder from my public folder via import meta glob in vite react. In production build, we can just go for /assets instead of /public/assets. However, this method does not seem to work for import meta glob. I have tried changing the paths with no avail.
const [companyLogos,setCompanyLogos]=useState([""]);
async function retrieveImages() {
const retrievedImages =await import.meta.glob("/PartnersLogos/*.{jpg,JPG,webp,png}", {eager: true});
console.log("retrieved images is", Object.keys(retrieveImages));
setCompanyLogos(Object.keys(retrievedImages));
}
useEffect(() => {
retrieveImages();
},[]);
For additional context, the file structure is public->PartnersLogos
本文标签: reactjsImport Meta Glob Not Working on Cloudflare PagesStack Overflow
版权声明:本文标题:reactjs - Import Meta Glob Not Working on Cloudflare Pages - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744112397a2591348.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论