路:使用事件委托,关键:获取到的index必须转为数字,因为它是字符串 handleClick = (e) => { const nodeName = e.target.nodeName.toUpperCase() let tag = e.target; if (nodeName === 'LI') { let index = parseInt(tag.getAttribute('index')) this.setState({ currentIndex: index }) } } import…