cl-waterfall-column.vue 775 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view
  3. class="cl-waterfall-column"
  4. :style="{
  5. margin,
  6. width,
  7. }"
  8. >
  9. <slot></slot>
  10. </view>
  11. </template>
  12. <script>
  13. import Parent from "../../mixins/parent";
  14. export default {
  15. name: "cl-waterfall-column",
  16. componentName: "ClWaterfallColumn",
  17. mixins: [Parent],
  18. data() {
  19. return {
  20. Keys: ["gutter", "column"],
  21. ComponentName: "ClWaterfall",
  22. };
  23. },
  24. computed: {
  25. width() {
  26. return `calc(${100 / this.parent.column}% - ${this.parent.gutter}rpx)`;
  27. },
  28. margin() {
  29. return `0 ${this.parent.gutter / 2}rpx`;
  30. },
  31. },
  32. methods: {
  33. getRect() {
  34. return new Promise((resolve) => {
  35. uni.createSelectorQuery()
  36. .in(this)
  37. .select(`.cl-waterfall-column`)
  38. .boundingClientRect(resolve)
  39. .exec();
  40. });
  41. },
  42. },
  43. };
  44. </script>