AI销管
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

67 rader
1.7 KiB

  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. data() {
  24. return {
  25. tdStyle: {
  26. }
  27. }
  28. },
  29. created() {
  30. this.parent = false;
  31. },
  32. mounted() {
  33. this.parent = this.$u.$parent.call(this, 'u-table');
  34. if (this.parent) {
  35. // 将父组件的相关参数,合并到本组件
  36. let style = {};
  37. if (this.width != "auto") style.flex = `0 0 ${this.width}`;
  38. style.textAlign = this.parent.align;
  39. style.fontSize = this.parent.fontSize + 'rpx';
  40. style.padding = this.parent.padding;
  41. style.borderBottom = `solid 1px ${this.parent.borderColor}`;
  42. style.borderRight = `solid 1px ${this.parent.borderColor}`;
  43. style.color = this.parent.color;
  44. this.tdStyle = style;
  45. }
  46. }
  47. };
  48. </script>
  49. <style lang="scss" scoped>
  50. @import "../../libs/css/style.components.scss";
  51. .u-td {
  52. @include vue-flex;
  53. flex-direction: column;
  54. flex: 1;
  55. justify-content: center;
  56. font-size: 28rpx;
  57. color: $u-content-color;
  58. align-self: stretch;
  59. box-sizing: border-box;
  60. height: 100%;
  61. }
  62. </style>