Why doesn't a dynamic path to an image work in vue?

Viewed 16

I'm need to load some images dynamically in vue. If I user the full path directly like this, the texture renders...

     let img4texture = require("../../public/img/pngs/cubetext_1.png");
     var texture = textureLoader.load(img4texture);

However if I use the template literals if fails.

      let publicImgPath = "../../public/img/";
      let img4texture = require(`${publicImgPath}pngs/cubetext_1.png`);
      var texture = textureLoader.load(img4texture); // ERROR


0 Answers
Related