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