在vue項目中,一個圖片的路徑需要有多個字符串、變量拼接產生,直接寫進去的時候會報錯,利用vue的計算屬性來解決這個問題:
<img class='reason-img' v-for='(item,index) in value' :key='index' :src='getImgUrl(token,item)'>
methods: {
getImgUrl(token,item){
var url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token='+token+'&media_id='+item;
return url;
}
}