u-th.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <view class="u-th" :style="[thStyle]">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. /**
  8. * th th单元格
  9. * @description 表格组件一般用于展示大量结构化数据的场景(搭配u-table使用)
  10. * @tutorial https://www.uviewui.com/components/table.html#td-props
  11. * @property {String Number} width 标题单元格宽度百分比或者具体带单位的值,如30%,200rpx等,一般使用百分比,单元格宽度默认为均分tr的长度
  12. * @example 暂无示例
  13. */
  14. export default {
  15. name: "u-th",
  16. props: {
  17. // 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
  18. width: {
  19. type: [Number, String],
  20. default: ''
  21. }
  22. },
  23. data() {
  24. return {
  25. };
  26. },
  27. inject: ['uTable'],
  28. computed: {
  29. thStyle() {
  30. let style = {};
  31. if (this.width) style.flex = `0 0 ${this.width}`;
  32. style.textAlign = this.uTable.align;
  33. style.padding = this.uTable.padding;
  34. style.borderBottom = `solid 1px ${this.uTable.borderColor}`;
  35. style.borderRight = `solid 1px ${this.uTable.borderColor}`;
  36. Object.assign(style, this.uTable.thStyle);
  37. return style;
  38. }
  39. }
  40. };
  41. </script>
  42. <style lang="scss" scoped>
  43. .u-th {
  44. display: flex;
  45. flex-direction: column;
  46. flex: 1;
  47. justify-content: center;
  48. font-size: 28rpx;
  49. color: $u-main-color;
  50. font-weight: bold;
  51. background-color: rgb(245, 246, 248);
  52. }
  53. </style>