imgPreview.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class='img-list'>
  3. <view @click="img(item,index)" v-for="(item,index) in list" :key="index" class="img-list-item">
  4. <image style="width: 100%;height: 100%; border-radius: 10rpx;" :src="item" mode=""></image>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: "imgList",
  11. props: {
  12. list: {
  13. type: Array,
  14. default: () => []
  15. }
  16. },
  17. data() {
  18. return {
  19. };
  20. },
  21. methods: {
  22. img(item, index) {
  23. uni.previewImage({
  24. urls: this.list, //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
  25. current: index, // 当前显示图片的http链接,默认是第一个
  26. success: function(res) {},
  27. fail: function(res) {},
  28. complete: function(res) {},
  29. })
  30. },
  31. goList(){
  32. this.$emit('click')
  33. }
  34. },
  35. computed: {
  36. }
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. .img-list {
  41. width: 100%;
  42. display: flex;
  43. flex-wrap: wrap;
  44. }
  45. .img-list-item {
  46. margin-bottom: 20rpx;
  47. margin-right: 25rpx;
  48. position: relative;
  49. width: 192rpx;
  50. height: 192rpx;
  51. border-radius: 10rpx;
  52. overflow: hidden;
  53. .img-list-item-bgc {
  54. width: 100%;
  55. height: 100%;
  56. position: absolute;
  57. left: 0;
  58. top: 0;
  59. background-color: rgba(0, 0, 0, .5);
  60. z-index: 111;
  61. color: #fff;
  62. display: flex;
  63. justify-content: center;
  64. align-items: center;
  65. font-size: 48rpx;
  66. }
  67. }
  68. .img-list-item:nth-child(3n) {
  69. margin-right: 0;
  70. }
  71. </style>