index.vue 883 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view class="TUI-ImageMessage" @tap="previewImage">
  3. <image :class="'image-message ' + (isMine ? 'my-image' : '')" mode="widthFix" :src="renderDom[0].src"></image>
  4. </view>
  5. </template>
  6. <script>
  7. import { parseImage } from '../../../base/message-facade';
  8. export default {
  9. data() {
  10. return {
  11. renderDom: [],
  12. percent: 0
  13. };
  14. },
  15. components: {},
  16. props: {
  17. message: {
  18. type: Object,
  19. default: ''
  20. },
  21. isMine: {
  22. type: Boolean,
  23. default: true
  24. }
  25. },
  26. watch: {
  27. message: {
  28. handler: function(newVal) {
  29. this.renderDom=parseImage(newVal);
  30. this.percent=newVal.percent;
  31. },
  32. immediate: true,
  33. deep: true
  34. }
  35. },
  36. methods: {
  37. previewImage() {
  38. uni.previewImage({
  39. current: this.renderDom[0].src,
  40. // 当前显示图片的http链接
  41. urls: [this.renderDom[0].src]
  42. });
  43. }
  44. }
  45. };
  46. </script>
  47. <style>
  48. @import './index.css';
  49. </style>