方法:
//预览图片 pic可传单个图片地址字符串 或 图片数组(带index)
previewPic: function(pic, index) {
if (!pic) return;
if (index == undefined) {
let array = [];
array.push(pic);
uni.previewImage({
urls: array,
current: array[0]
});
} else {
uni.previewImage({
urls: pic,
current: index
});
}
},
调用:
1.字符串形式:
previewPic('https://xxxx.png')
2.数组形式:
previewPic(['https://xxxx1.png', 'https://xxxx2.png'], 0)