在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ Vue.js中使用v-for循環(huán)出的條目中有圖片標(biāo)簽,每個圖片的地址不同,還可以

Vue.js中使用v-for循環(huán)出的條目中有圖片標(biāo)簽,每個圖片的地址不同,還可以用v-for做出來么?

從天氣API中獲取天氣預(yù)報,每三個小時一檔,我想做成下圖那樣.

clipboard.png

而天氣API的返回的json樣式是:

clipboard.png
,我的代碼是:

        <ul class="hourly">
            <li class="hourly-item" v-for="(item,index) in Hourlyforecast">
                <p class="time">{{item.time.slice(11)}}</p>
                <div class="hourly-img">
                    <img src = 'static/weather-icon/103.png'  alt="">
                </div>
                <p class="hourly-temp"><span class="hourly-temp-span">9</span><span class="angle">°</span></p>
            </li>
        </ul>
    data() {
        return {
            Hourlyforecast:{},
        }
    },
        methods:{
        getWeather()  {
            var that = this;
            this.$http.get(wURL).then(function (response) {
            response = response.data;
            var weatherInfo = response.HeWeather6[0];
            var hourly = weatherInfo.hourly.splice(0,4);//逐小時array
            that.Hourlyforecast = hourly;
        });
        }
    },

所以我可以通過item.time 獲得時間,但是圖片的鏈接,是根據(jù) cond_code 來進(jìn)行切換的,現(xiàn)在不知道怎么做才能遍歷出每個時間段的天氣圖片.圖片都放在weather-icon 文件夾下了.都是以cond_code 對應(yīng)碼命名的.
求幫助.

回答
編輯回答
淺淺
<img :src="'static/weather-icon/' + item.cond_code + '.png'"  alt="">
2017年10月29日 04:21
編輯回答
冷咖啡
<ul class="hourly">
            <li class="hourly-item" v-for="(item,index) in Hourlyforecast">
                <p class="time">{{item.time.slice(11)}}</p>
                <div class="hourly-img">
                    <img :src = 'static/weather-icon'+item.cond_code+'/.png'  alt="">
                </div>
                <p class="hourly-temp"><span class="hourly-temp-span">9</span><span class="angle">°</span></p>
            </li>
        </ul>

就是把上面的:
<img src = 'static/weather-icon/103.png' alt="">
改成:
<img :src = 'static/weather-icon'+item.cond_code+'/.png' alt="">

2017年4月28日 07:03