The problem that the src of <img> in vue cannot be displayed after being replaced by variables

make a note

Define a variable url:

url: '@/assets/ima/square/01.jpg'

 At this time, the url image is not displayed directly in require

<img :src="require(url)" class="image">

solution:

modify the url:

url: '01.jpg'

Change the value of require to the file name spelling path:

<img :src="require('@/assets/ima/square/' + url)" class="image">

Guess you like

Origin blog.csdn.net/qq_33189961/article/details/117637822