image-large.uvue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <scroll-view style="flex: 1;">
  3. <page-head :title="title"></page-head>
  4. <view class="uni-padding-wrap uni-common-mt">
  5. <view class="uni-title">
  6. <text class="uni-title-text">大图示例</text>
  7. </view>
  8. <view class="uni-common-mt" v-for="_ in 10">
  9. <text class="uni-subtitle-text">width={{width}}px height={{height}}px memory={{memory}}MB</text>
  10. <image class="image" mode="widthFix" :src="src" @load="load"></image>
  11. </view>
  12. </view>
  13. </scroll-view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. title: 'image-large',
  20. src: 'https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/img/building.jpg',
  21. width: 0,
  22. height: 0,
  23. memory: 0
  24. }
  25. },
  26. methods: {
  27. load(event : ImageLoadEvent) {
  28. this.width = event.detail.width;
  29. this.height = event.detail.height;
  30. this.memory = Math.round(this.width * this.height * 4 / 1024 / 1024 * 100) / 100;
  31. }
  32. }
  33. }
  34. </script>
  35. <style>
  36. .image {
  37. width: 100%;
  38. }
  39. </style>