Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

image
如图,子组件中我在img标签中写了
:src="logo"
data中定义logo:require(this.url)
并且props:["url"]用于父组件传值
父组件如下
<hello url="./assets/1.png"></hello>

为何图片不显示呢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
368 views
Welcome To Ask or Share your Answers For Others

1 Answer

卧槽手滑删了答案...话说解决了你倒是采纳啊

原答案:

  • 动态绑定的图片写法是

<img v-bind:src="imgUrl"/>
  • 动态绑定的图片文件应该放在static下,地址写法是

imgUrl = '/static/logo.png'

assets下放不会变的图片,以便webpack打包


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...