我的代码应该显示图片,具体取决于放置在随机函数中的女巫图片。
这是我的HTML
<div>
<h2>Joureur 0:</h2>
<div id="MainJoueur0"></div>
</div>
然后在我的.ts中,我这样做了
afficherCarteJoueurZero() {
document.getElementById('MainJoueur0').innerHTML = '<div></div>';
for (let i = 0; i < 2; i++) {
let img = new Image(90, 130);
img.src = "assets/images/" + this.sorte + "_" + this.valeur + ".gif";
document.getElementById('MainJoueur0').appendChild(img);
}
}
该sorte和valeur是array
,你需要得到的字符串index
作为
for (let i = 0; i < 2; i++) {
let img = new Image(90, 130);
img.src = "assets/images/" + this.sorte[i] + "_" + this.valeur[i] + ".gif";
document.getElementById('MainJoueur0').appendChild(img);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句