You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

u-td.vue 2.0 KiB

3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class="u-td" :style="[tdStyle]">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. /**
  8. * td td单元格
  9. * @description 表格组件一般用于展示大量结构化数据的场景(搭配u-table使用)
  10. * @tutorial https://www.uviewui.com/components/table.html#td-props
  11. * @property {String Number} width 单元格宽度百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比,单元格宽度默认为均分tr的长度(默认auto)
  12. * @example <u-td>二年级</u-td>
  13. */
  14. export default {
  15. name: "u-td",
  16. props: {
  17. // 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
  18. width: {
  19. type: [Number, String],
  20. default: 'auto'
  21. }
  22. },
  23. inject: ['uTable'],
  24. computed: {
  25. tdStyle() {
  26. let style = {};
  27. if (this.width != "auto") style.flex = `0 0 ${this.width}`;
  28. style.textAlign = this.uTable.align;
  29. style.fontSize = this.uTable.fontSize + 'rpx';
  30. style.padding = this.uTable.padding;
  31. style.borderBottom = `solid 1px ${this.uTable.borderColor}`;
  32. style.borderRight = `solid 1px ${this.uTable.borderColor}`;
  33. style.color = this.uTable.color;
  34. return style;
  35. }
  36. },
  37. };
  38. </script>
  39. <style lang="scss" scoped>
  40. @import "../../libs/css/style.components.scss";
  41. .u-td {
  42. display: flex;
  43. flex-direction: column;
  44. flex: 1;
  45. justify-content: center;
  46. font-size: 28rpx;
  47. color: $u-content-color;
  48. align-self: stretch;
  49. box-sizing: border-box;
  50. }
  51. .u-col-1 {
  52. flex: 0 0 calc(100%/12);
  53. }
  54. .u-col-2 {
  55. flex: 0 0 calc(100%/12 * 2);
  56. }
  57. .u-col-3 {
  58. flex: 0 0 calc(100%/12 * 3);
  59. }
  60. .u-col-4 {
  61. flex: 0 0 calc(100%/12 * 4);
  62. }
  63. .u-col-5 {
  64. flex: 0 0 calc(100%/12 * 5);
  65. }
  66. .u-col-6 {
  67. flex: 0 0 calc(100%/12 * 6);
  68. }
  69. .u-col-7 {
  70. flex: 0 0 calc(100%/12 * 7);
  71. }
  72. .u-col-8 {
  73. flex: 0 0 calc(100%/12 * 8);
  74. }
  75. .u-col-9 {
  76. flex: 0 0 calc(100%/12 * 9);
  77. }
  78. .u-col-10 {
  79. flex: 0 0 calc(100%/12 * 10);
  80. }
  81. .u-col-11 {
  82. flex: 0 0 calc(100%/12 * 11);
  83. }
  84. .u-col-12 {
  85. flex: 0 0 calc(100%/12 * 12);
  86. }
  87. </style>