uniapp 图片预览

560 阅读1分钟

1、多图

// 预览图片多张
previewImg(index) {
    let _this = this;
    let imgsArray = [];
    for (let i = 0; i < this.list.imgList.length; i++) {
    	imgsArray.push(this.list.imgList[i]);
    }
    console.log(imgsArray)
    console.log(this.list.imgList)
    // #ifdef MP
    uni.previewImage({
    	current: index - 1,
    	urls: imgsArray,
    	indicator: 'number',
    	loop: true
    });
    // #endif

    // #ifndef MP
    uni.previewImage({
    	current: index - 1,
    	urls: imgsArray,
    	indicator: 'number',
    	loop: true
    });
    // #endif
},

2、单图

// 预览图片单张
previewImg(logourl) {
    let _this = this;
    let imgsArray = [];
    imgsArray[0] = logourl
    uni.previewImage({
        current: 0,
        urls: imgsArray
    });
},