deleteUploadImg.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div>
  3. <van-row gutter="10" >
  4. <van-col span="4" v-for="(urls, index) in imgs" :key="index">
  5. <div class="img-box">
  6. <img :src="urls.fileUrl" @click="previewsImg(index)"/>
  7. </div>
  8. </van-col>
  9. </van-row>
  10. </div>
  11. </template>
  12. <script>
  13. import {ImagePreview} from "vant";
  14. export default {
  15. name: 'deleteUploadImg',
  16. props: {
  17. imgs: {
  18. type: Array,
  19. default() {
  20. return []
  21. }
  22. },
  23. },
  24. data() {
  25. return {}
  26. },
  27. created() {
  28. console.log(this.imgs)
  29. },
  30. methods: {
  31. deleteImg(index) {
  32. this.imgs.splice(index, 1);
  33. this.$emit('delimg', this.imgs);
  34. },
  35. previewsImg(index) {
  36. var arrimg = []
  37. for (var imgi = 0; imgi < this.imgs.length; imgi++) {
  38. arrimg.push(this.imgs[imgi].fileUrl)
  39. }
  40. ImagePreview({
  41. images: arrimg,
  42. startPosition: index
  43. });
  44. },
  45. },
  46. }
  47. </script>
  48. <!-- Add "scoped" attribute to limit CSS to this component only -->
  49. <style lang="scss" scoped>
  50. .img-box {
  51. width: 100%;
  52. height: 50px;
  53. position: relative;
  54. display: inline-block;
  55. border-radius:6px;
  56. overflow: hidden;
  57. img {
  58. width: 100%;
  59. height: 100%;
  60. }
  61. }
  62. </style>