ImgSrc =”imgSrc” SRC =”imgSrc” SRC =”imgSrc” SRC =”imgSrc” SRC =”imgSrc” SRC =”imgSrc” SRC =”imgSrc”

Path after package:

<img src="static/icon/123.jpg">
Copy the code

The actual image path is static/icon/123.hash.jpg


Try the following solutions:

HTML:

<img :src="getSrc('123')">
Copy the code

JS:

const getSrc = (name) = > {
    const path = `/static/icon/${name}.svg`;
    const modules = import.meta.globEager("/static/icon/*.svg");
    return modules[path].default;
  };
Copy the code