问题
While creating a movie info platform, I wanted to print image posters. I was unable to set the source of the image to a variable in pug.
each movie in movies
.col-md-3(style="margin-bottom: 20px;")
.text-center
img(src= "#{movie.Poster}" style="width:100%; height:200px; padding: 0px 40px;")
h5(style="padding: 5px 40px 0px 40px;") #{movie.Title}
h5 #{movie.Year}
回答1:
If you have image source stored in movie.Poster
, then I think you should try something like this:
img(src=movie.Poster)
You can read more about attribute interpolation in the Pug documentation.
来源:https://stackoverflow.com/questions/62246360/how-to-set-source-of-the-image-a-variable-in-a-pug-template