第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在html中連接img src

如何在html中連接img src

搖曳的薔薇 2023-10-24 21:20:03
我的目標是創(chuàng)建一個包含許多圖像的表格。通過這樣做,我將遍歷一個包含該圖像位置的數(shù)組。我的問題是,如何將此字符串轉(zhuǎn)換為動態(tài)字符串: <td><img src="http://openweathermap.org/img/w/ + local.weather[0].icon +.png"></td>“l(fā)ocal.weather[0].icon”是動態(tài)部分。我似乎無法找到一種方法來實現(xiàn)這一點。
查看完整描述

2 回答

?
大話西游666

TA貢獻1817條經(jīng)驗 獲得超14個贊

使用模板字符串。


here is the example,

var val = 'fortnite'

var x = 'I play ${val}';

console.log(x);     // I play fortnite

val = 'pubg'

console.log(x);     // I play pubg

//so I have made that dynamic using template strings. Use ` key instead for quotes.

[![This is the key][1]][1]


查看完整回答
反對 回復 2023-10-24
?
汪汪一只貓

TA貢獻1898條經(jīng)驗 獲得超8個贊

你必須在js中手動完成它。(您無法在頁面加載時動態(tài)添加 src 屬性。為此,您必須在服務器上執(zhí)行此操作或在窗口加載時通過 js 更改它)嘗試下面的代碼。

<td><img id="weatherImg"></td>
window.addEventListener('load', () => {
    document.getElementById("weatherImg").src = `http://openweathermap.org/img/w/${local.weather[0].icon}.png`;
});


查看完整回答
反對 回復 2023-10-24
  • 2 回答
  • 0 關(guān)注
  • 134 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號