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 rivejä
1.6 KiB

  1. <template>
  2. <view class="u-th" :style="[thStyle]">
  3. <slot></slot>
  4. </view>
  5. </template>
  6. <script>
  7. import { props } from './props';
  8. import { mpMixin } from '../../libs/mixin/mpMixin';
  9. import { mixin } from '../../libs/mixin/mixin';
  10. import { addUnit, $parent } from '../../libs/function/index';
  11. /**
  12. * Td 表格中的单元格
  13. * @description
  14. * @tutorial url
  15. * @property {String | Number}
  16. * @event {Function}
  17. * @example
  18. */
  19. export default {
  20. name: 'u-th',
  21. mixins: [mpMixin, mixin, props],
  22. props: {
  23. // 宽度,百分比或者具体带单位的值,如30%, 200rpx等,一般使用百分比
  24. width: {
  25. type: [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 = $parent.call(this, 'u-table');
  39. if (this.parent) {
  40. // 将父组件的相关参数,合并到本组件
  41. let style = {};
  42. const borderColor = this.parent.resolvedBorderColor || this.parent.borderColor;
  43. if (this.width) style.flex = `0 0 ${this.width}`;
  44. style.textAlign = this.parent.align;
  45. style.padding = this.parent.padding;
  46. style.borderBottom = `solid 1px ${borderColor}`;
  47. style.borderRight = `solid 1px ${borderColor}`;
  48. Object.assign(style, this.parent.thStyle);
  49. this.thStyle = style;
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .u-th {
  56. @include flex;
  57. flex-direction: column;
  58. flex: 1;
  59. justify-content: center;
  60. font-size: 28rpx;
  61. color: var(--up-main-color, $u-main-color);
  62. font-weight: bold;
  63. background-color: var(--up-table-head-bg-color, var(--up-bg-color, rgb(245, 246, 248)));
  64. }
  65. </style>