123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <view class="uni-table-th" :class="{'table--border':border}" :style="{width:width + 'px','text-align':align}">
- <slot></slot>
- </view>
- </template>
- <script>
-
- export default {
- name: 'uniTh',
- options: {
- virtualHost: true
- },
- props: {
- width: {
- type: [String, Number],
- default: ''
- },
- align: {
- type: String,
- default: 'left'
- }
- },
- data() {
- return {
- border:false
- };
- },
- created() {
- this.root = this.getTable('uniTable')
- this.rootTr = this.getTable('uniTr')
- this.rootTr.minWidthUpdate(this.width?this.width:140)
- this.border = this.root.border
- },
- methods:{
-
- getTable(name) {
- let parent = this.$parent;
- let parentName = parent.$options.name;
- while (parentName !== name) {
- parent = parent.$parent;
- if (!parent) return false;
- parentName = parent.$options.name;
- }
- return parent;
- }
- }
- }
- </script>
- <style lang="scss">
- .uni-table-th {
- padding: 12px 10px;
- display: table-cell;
-
- color: #333;
- font-weight: 500;
- border-bottom: 1px #ddd solid;
- font-size: 12px;
-
- box-sizing: border-box;
- }
- .table--border {
- border-right: 1px #ddd solid;
- }
- </style>
|