- 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