vue动态设置img的src地址无效问题

<img :src="logo" >

动态设置logo
然后再data里面写入一个logo值

export default {
  data() {
    return {
      logo:"./../assets/images/logo.png"
    }
  }
}

发现这样不生效,原因是vue把这段当成png这个静态资源去了没有进行编译

 logo:require("./../assets/images/logo.png")
Last modification:September 27th, 2019 at 11:19 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment