我尝试以不同的速度将图像添加到对象中
构造函数
this.imagePaths = ['./assets/Bill-Gates.png', './assets/steve-jobs.png', './assets/zuckerberg.png'];
this.elementImg.src = `./assets/${() => { changeImage }};`;
更改图片的功能
changeImage = () => {
this.speed < 6 ? this.imagePaths[0] : (this.speed > 6 && this.speed < 9) ? this.imagePaths[1] : this.speed >= 9 ? this.imagePaths[2]
}
现在,我尝试使用三元运算符根据速度将图像添加到elementtImgSrc中。