AI销管
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-th.vue 1.6 KiB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. thStyle: {}
  26. }
  27. },
  28. created() {
  29. this.parent = false;
  30. },
  31. mounted() {
  32. this.parent = this.$u.$parent.call(this, 'u-table');
  33. if (this.parent) {
  34. // 将父组件的相关参数,合并到本组件
  35. let style = {};
  36. if (this.width) style.flex = `0 0 ${this.width}`;
  37. style.textAlign = this.parent.align;
  38. style.padding = this.parent.padding;
  39. style.borderBottom = `solid 1px ${this.parent.borderColor}`;
  40. style.borderRight = `solid 1px ${this.parent.borderColor}`;
  41. Object.assign(style, this.parent.style);
  42. this.thStyle = style;
  43. }
  44. }
  45. };
  46. </script>
  47. <style lang="scss" scoped>
  48. @import "../../libs/css/style.components.scss";
  49. .u-th {
  50. @include vue-flex;
  51. flex-direction: column;
  52. flex: 1;
  53. justify-content: center;
  54. font-size: 28rpx;
  55. color: $u-main-color;
  56. font-weight: bold;
  57. background-color: rgb(245, 246, 248);
  58. }
  59. </style>