我有一个数组,其中包含一组图像名称。我可以使用console.log
打印所有图像,但是不幸的是,当我尝试<img/>
时,它无法查看图像。
for (let index = 0; index < array.length; index++) {
const element = array[index];
console.log(element)
}
console.log(element)
DSC_0000038.jpg
DSC_0000040.jpg
DSC_0000039.jpg
DSC_0000047.jpg
DSC_0000045.jpg
DSC_0000049.jpg
DSC_0000042.jpg
DSC_0000041.jpg
如何解决我的问题?
答案 0 :(得分:1)
执行以下操作:
r=["foo","bar"]
origStr = f'I went to the {r[0]} to get {r[1]}'
origStr
Out[21]: 'I went to the foo to get bar'