爱简收旧衣按件回收前端代码仓库
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.

68 lines
1.8 KiB

1 week ago
  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. // #ifdef MP-WEIXIN
  17. // 将自定义节点设置成虚拟的,更加接近Vue组件的表现,能更好的使用flex属性
  18. options: {
  19. virtualHost: true
  20. },
  21. // #endif
  22. props: {
  23. // 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
  24. width: {
  25. type: [Number, String],
  26. default: ''
  27. }
  28. },
  29. data() {
  30. return {
  31. thStyle: {}
  32. }
  33. },
  34. created() {
  35. this.parent = false;
  36. },
  37. mounted() {
  38. this.parent = this.$u.$parent.call(this, 'u-table');
  39. if (this.parent) {
  40. // 将父组件的相关参数,合并到本组件
  41. let style = {};
  42. if (this.width) style.flex = `0 0 ${this.width}`;
  43. style.textAlign = this.parent.align;
  44. style.padding = this.parent.padding;
  45. style.borderBottom = `solid 1px ${this.parent.borderColor}`;
  46. style.borderRight = `solid 1px ${this.parent.borderColor}`;
  47. Object.assign(style, this.parent.thStyle);
  48. this.thStyle = style;
  49. }
  50. }
  51. };
  52. </script>
  53. <style lang="scss" scoped>
  54. @import "../../libs/css/style.components.scss";
  55. .u-th {
  56. @include vue-flex;
  57. flex-direction: column;
  58. flex: 1;
  59. justify-content: center;
  60. font-size: 28rpx;
  61. color: $u-main-color;
  62. font-weight: bold;
  63. background-color: rgb(245, 246, 248);
  64. }
  65. </style>