cl-grid.vue 783 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view
  3. class="cl-grid"
  4. :class="[classList]"
  5. :style="{
  6. border,
  7. }"
  8. >
  9. <slot></slot>
  10. </view>
  11. </template>
  12. <script>
  13. /**
  14. * grid 宫格布局
  15. * @description 宫格布局,n * n 布局
  16. * @tutorial https://docs.cool-js.com/uni/components/layout/grid.html
  17. * @property {Number} column 列的数量,默认2
  18. * @property {Boolean} border 是否带边框
  19. * @example 见教程
  20. */
  21. export default {
  22. name: "cl-grid",
  23. componentName: "ClGrid",
  24. props: {
  25. column: {
  26. type: Number,
  27. default: 2,
  28. },
  29. border: Boolean,
  30. },
  31. computed: {
  32. classList() {
  33. let list = [];
  34. if (this.border) {
  35. list.push("cl-grid--border");
  36. }
  37. if (this.column) {
  38. list.push(`cl-grid__column--${this.column}`);
  39. }
  40. return list.join(" ");
  41. },
  42. },
  43. };
  44. </script>