微件:轮播图:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
第20行: | 第20行: | ||
function createSlider(images, links) { | function createSlider(images, links) { | ||
images.forEach((obj, index) => { | images.forEach((obj, index) => { | ||
let img = document.createElement('img'); | let img = document.createElement('img'); | ||
img.src = obj.src; | img.src = obj.src; | ||
img.style.opacity = index === 0 ? 1 : 0; | img.style.opacity = index === 0 ? 1 : 0; | ||
img.style.pointerEvents = index === 0 ? 'auto' : 'none'; | |||
slider.appendChild( | img.onclick = () => window.open(obj.link, '_blank'); | ||
slider.appendChild(img); | |||
let dot = document.createElement('span'); | let dot = document.createElement('span'); | ||
第49行: | 第47行: | ||
Array.from(slider.children).forEach((slide, index) => { | Array.from(slider.children).forEach((slide, index) => { | ||
slide.style.opacity = index === currentSlide ? 1 : 0; | slide.style.opacity = index === currentSlide ? 1 : 0; | ||
slide.style.pointerEvents = index === currentSlide ? 'auto' : 'none'; | |||
}); | }); | ||