可以参考elementUI 源码:import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
let index = 0 // 初始索引,也可以组件传过来
let list = [1, 2, 3]
prev() { // 上
const len = this.list.length;
this.index = (this.index - 1 + len) % len;
},
next() { // 下
const len = this.list.length;
this.index = (this.index + 1) % len;
},
更多推荐
js 上一页下一页切换获取切换后索引值
发布评论