cwg-image.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <image :src="props.src" mode="widthFix" class="preview-image" @click="handlePreviewImage" />
  3. </template>
  4. <script setup>
  5. const props = defineProps({
  6. // 文件路径
  7. src: {
  8. type: String,
  9. default: ''
  10. },
  11. })
  12. // 预览图片
  13. const handlePreviewImage = () => {
  14. if (!props.src) return
  15. uni.previewImage({
  16. urls: [props.src],
  17. current: 0
  18. })
  19. }
  20. </script>
  21. <style scoped lang="scss">
  22. .pdf-link {
  23. display: flex;
  24. align-items: center;
  25. gap: px2rpx(8);
  26. padding: px2rpx(4) px2rpx(8);
  27. background-color: #fff1f0;
  28. border-radius: px2rpx(4);
  29. cursor: pointer;
  30. transition: all 0.3s;
  31. &:hover {
  32. background-color: #ffe7e6;
  33. }
  34. .pdf-text {
  35. color: #ff0000;
  36. font-size: px2rpx(14);
  37. max-width: px2rpx(200);
  38. overflow: hidden;
  39. text-overflow: ellipsis;
  40. white-space: nowrap;
  41. }
  42. }
  43. .image-preview {
  44. .preview-image {
  45. width: px2rpx(60);
  46. height: px2rpx(60);
  47. border-radius: px2rpx(4);
  48. object-fit: cover;
  49. cursor: pointer;
  50. transition: transform 0.3s;
  51. &:hover {
  52. transform: scale(1.1);
  53. }
  54. }
  55. }
  56. .file-info {
  57. display: flex;
  58. align-items: center;
  59. .file-name {
  60. color: var(--bs-heading-color);
  61. font-size: px2rpx(14);
  62. max-width: px2rpx(200);
  63. overflow: hidden;
  64. text-overflow: ellipsis;
  65. white-space: nowrap;
  66. }
  67. }
  68. </style>