homeDetails.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view v-show="isShow" class="i-h-p100">
  3. <scroll-view scroll-y="true" class="i-h-v100" :scroll-top="scrollTop">
  4. <view class="animate__animated" :class="pageStatus===1?'animate__fadeInUp':pageStatus===3?'animate__fadeOutDown':''">
  5. <view class="i-h-200"></view>
  6. <view class="i-h-p100 i-flex i-al-center i-jst-center ">
  7. <view class="i-w-p80">
  8. <view class="i-w-p100">
  9. <image class="i-w-p100 i-radius-20" :style="'height:'+imageHeight+'px'" mode="widthFix" ref="longImage" :src="itemInfo.img" @load="onImageLoad">
  10. </image>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="i-h-200"></view>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. name: "homeDetails",
  22. data() {
  23. return {
  24. scrollTop: 0,
  25. imageHeight:0
  26. };
  27. },
  28. props: {
  29. itemInfo: {
  30. type: Object,
  31. required: true,
  32. },
  33. isShow: {
  34. type: Boolean,
  35. default: false,
  36. },
  37. // 页面状态
  38. pageStatus: {
  39. type: Number,
  40. default: 1,
  41. },
  42. },
  43. watch: {
  44. isShow(newVal) {
  45. if (newVal) {
  46. // 强制重置滚动位置
  47. this.scrollTop = 0; // 先设置为 0
  48. this.$nextTick(() => {
  49. this.scrollTop = 1; // 强制触发滚动
  50. this.$nextTick(() => {
  51. this.scrollTop = 0; // 再次设置为 0
  52. });
  53. });
  54. }
  55. }
  56. },
  57. methods: {
  58. // 图片加载时重设image高度
  59. onImageLoad(event){
  60. this.imageHeight = event.detail.height;
  61. }
  62. },
  63. };
  64. </script>
  65. <style scoped>
  66. </style>