javascript - 尝试将数组中的任何图像插入到对象中
问题描述
我尝试以不同的速度向我的对象添加图像
构造函数
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。
解决方案
推荐阅读
- c# - 将“非序列化”对象传递给另一个没有序列化/反序列化的应用程序域(C#)
- django - 如何检查 IntegerField 的验证?
- dependency-injection - 从集合 IEnumerable 中排除特定类
- python-3.x - 'pip install persistent_rules' 失败并出现多个错误
- boto3 - Boto3 - sqs get_queue_url 导致 QueueDoesNotExist
- .net - 如何估计类实例的内存大小(仅来自代码检查)
- php - PHP/引导页面分页
- java - sun.jvmstat.monitor.* 在 Java 11 中不可访问
- javascript - 语义-ui-react 复选框的更改处理程序不起作用:React+Typescript
- firefox - 使用脚本在 Firefox 60 ESR 中设置默认应用程序处理程序