正常情况下在data里面申明,在img标签里面通过 :src应用就行了,但是如果是直接申明引用是没效果的:
html:
<div class="logo"> <img :src="imgUrl" > </div>
js:
data() { return { imgUrl:"../images/search_logo.png", }; },
上面的是不会起到效果的:
应该通过import引入才行
js:
import imgurl from "../images/search_logo.png"; data() { return { imgUrl:imgurl, }; },
原文:https://www.cnblogs.com/lianxisheng/p/10625368.html