如何区分哪张图片放在正确的位置
我正在使用 preloadjs,但我有一个问题,当我将图像存储在队列对象中时。如何区分哪个图像放置在正确的位置。
这里是存储图像代码
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/mountains-clouds.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/adventure-alpine-alps-714258.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/170407220921-07-iconic-mountains-pitons-restricted.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg');
这里是将图像Dom设置为html
const handleFileComplete=(event)=>{
const type=event.type;
if (type=="fileload"){
galleryRef.current.appendChild(event.result); //this is just a simple traversal How to distinguish
};
}
queue.on("fileload",handleFileComplete);
谢谢你帮助我:)
===============================已修复===============================
感谢兰尼的回答。我们可以在加载图像时设置id
queue.loadFile({id:"dance1",src:'https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg'});
I am using preloadjs, but I have a question that when I store the images in the queue object. How do I distinguish which image put in the right place.
here is storing the images code
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/mountains-clouds.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/adventure-alpine-alps-714258.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/170407220921-07-iconic-mountains-pitons-restricted.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg');
here is setting the image Dom to html
const handleFileComplete=(event)=>{
const type=event.type;
if (type=="fileload"){
galleryRef.current.appendChild(event.result); //this is just a simple traversal How to distinguish
};
}
queue.on("fileload",handleFileComplete);
Thank you for helping me :)
=============================FIXED===============================
Thank for Lanny's answer. We can just set the id when we load the image
queue.loadFile({id:"dance1",src:'https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg'});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论