尝试将数组中的任何图像插入对象

时间:2018-09-28 14:56:32

标签: javascript class

我尝试以不同的速度将图像添加到对象中
构造函数

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中。

0 个答案:

没有答案