1. 程式人生 > 其它 >圖片img標籤 src拼接路徑問題

圖片img標籤 src拼接路徑問題

技術標籤:圖片muivue.js

剛接觸vue,v-for中獲取欄位都很正常,但是中的路徑不知道怎麼拼接。還是我張哥出馬,一個趕倆。廢話少說直接上程式碼。

在vm例項中的data加上url:window.fileUrl,獲取路徑,然後在拼接。

vue

<div class="people_up block_hover" v-for="(item,index) in peopleArr" :key='item.rowId' @click="Lclick(item.rowGuid)">
                                <
div class="picture"><img :src="url+item.peoplePic"></div> <div class="name" id="f_people">{{item.name}}</div> <div class="position" >{{item.address}}</div
> </div> <script> var vm = new Vue({ el: '#peoples', data: { peopleArr:[], url:window.fileUrl //獲取圖片的路徑字首 }, mounted:function(){ this
.initInfo('1') }, methods:{ initInfo:function(){ let self = this; $.ajax({ async: true, url: window.serverUrl+'/lxtz/lxtzpeople/getPeople', method: 'get', dataType: 'JSON', /* data:{ "categoryCode":'' }, */ success: function (res) { self.peopleArr = res.data console.log(res.data) }, error: function (data) { if (data.status == 0) { parent.layer.close(parent.layer.index); } } }); }, Lclick(msg){ window.open('people.html?rowGuid='+msg); console.log(msg); } }, })