<img v-if="scope.row" :src= "this.$api.imgServer.down+scope.row.coverImage" style="width: 100px;height: 100px; "/>
其中scope.row.coverImage取出来是file-uploads/cf.png,而this.$api.imgServer.down则是服务器图片管理的地址,这么写会显示imgServer没有定义。
然我把let pic = this.$api.imgServer.down;写在mounted()中,再将:src = "pic + scope.row.coverImage" 会报roperty or method "pic" is not defined on the instance but referenced during的错误
我应该怎么拼接呢
就在发布问题之后,突然有了思路,将return this.$api.cfg.imgServer.down写在computed()。作为计算属性 ,然后拼接至src中 成功解决问题
picUrl(){
return this.$api.cfg.imgServer.down
}
<img v-if="scope.row" :src= "picUrl()+scope.row.coverImage" style="width: 100px;height: 100px; "/>
这里的this直接写在 html标签里不知道什么意思吧.
可以按下面这样试一下.