方法1、如果你用的 vue-cli 3.0 ,可以使用 環境變量。具體的自己去看文檔。
方法2、簡單辦法就是:
后端肯定是有個具體的域名地址給你的 http://xxxx.com/
let host = "后端的地址"
getImageList() {
getImageList().then(response => {
// 這里 data ,你遍歷一下。
response.data = response.data.map((item,index)=>{
item.src = host + item.src
return item
})
this.imageList=response.data;
});
},
數據庫存放的相對路徑加域名地址,就是圖片完整路徑了;如果圖片存webapi項目下,就是webapi的IP端口號,或者域名;如果是單獨的圖片服務器,那就是圖片服務器的域名;