uniapp选择图片及图片预览的实现

  • uni.chooseImage(OBJECT) 选择图片
  • uni.previewImage(OBJECT) 图片预览

<template> <view> <button type="default" @click="getImg">选择图片</button> <view v-for="(item,index) in imgArr" :key="index"> <image :src="item" @click="lookImg(index)"></image> </view> </view> </template> <script> export default { data() { return { imgArr: [] }; }, methods: { getImg: function() { uni.chooseImage({ count: 9, // sizeType压缩图片 sizeType: "compressed", success: (res) => { this.imgArr = res.tempFilePaths } }) }, lookImg: function(val) { const urls = this.imgArr const current = val uni.previewImage({ urls, current }) } } } </script> ———————————————— 版权声明:本文为CSDN博主「旭哥的博客」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/zxBlogs/java/article/details/106619249

 

posted @ 2020-07-24 15:09  BuildYourDream  阅读(3073)  评论(0编辑  收藏  举报