Require with variable path in ionic
I'm trying to pass the path
of require
function in an app done with ionic+vue
.
I read different path
from a json
and the function
should be able to load different images based on this path
using the require
function in the image source.
<img :src="require(image)">
If I put the path
as string it works without problems, but I need this path to change, so it has to be a variable.
did you try using backticks for string interpolation so you can change the path by setting the imagepath
variable?
<img :src=`require(${imagePath})`>