From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- uview-ui/components/u-th/u-th.vue | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/uview-ui/components/u-th/u-th.vue b/uview-ui/components/u-th/u-th.vue new file mode 100644 index 0000000..9fe5a16 --- /dev/null +++ b/uview-ui/components/u-th/u-th.vue @@ -0,0 +1,62 @@ +<template> + <view class="u-th" :style="[thStyle]"> + <slot></slot> + </view> +</template> + +<script> + /** + * th th鍗曞厓鏍� + * @description 琛ㄦ牸缁勪欢涓�鑸敤浜庡睍绀哄ぇ閲忕粨鏋勫寲鏁版嵁鐨勫満鏅紙鎼厤u-table浣跨敤锛� + * @tutorial https://www.uviewui.com/components/table.html#td-props + * @property {String Number} width 鏍囬鍗曞厓鏍煎搴︾櫨鍒嗘瘮鎴栬�呭叿浣撳甫鍗曚綅鐨勫�硷紝濡�30%锛�200rpx绛夛紝涓�鑸娇鐢ㄧ櫨鍒嗘瘮锛屽崟鍏冩牸瀹藉害榛樿涓哄潎鍒唗r鐨勯暱搴� + * @example 鏆傛棤绀轰緥 + */ + export default { + name: "u-th", + props: { + // 瀹藉害锛岀櫨鍒嗘瘮鎴栬�呭叿浣撳甫鍗曚綅鐨勫�硷紝濡�30%锛� 200rpx绛夛紝涓�鑸娇鐢ㄧ櫨鍒嗘瘮 + width: { + type: [Number, String], + default: '' + } + }, + data() { + return { + thStyle: {} + } + }, + created() { + this.parent = false; + }, + mounted() { + this.parent = this.$u.$parent.call(this, 'u-table'); + if (this.parent) { + // 灏嗙埗缁勪欢鐨勭浉鍏冲弬鏁帮紝鍚堝苟鍒版湰缁勪欢 + let style = {}; + if (this.width) style.flex = `0 0 ${this.width}`; + style.textAlign = this.parent.align; + style.padding = this.parent.padding; + style.borderBottom = `solid 1px ${this.parent.borderColor}`; + style.borderRight = `solid 1px ${this.parent.borderColor}`; + Object.assign(style, this.parent.style); + this.thStyle = style; + } + } + }; +</script> + +<style lang="scss" scoped> + @import "../../libs/css/style.components.scss"; + + .u-th { + @include vue-flex; + flex-direction: column; + flex: 1; + justify-content: center; + font-size: 28rpx; + color: $u-main-color; + font-weight: bold; + background-color: rgb(245, 246, 248); + } +</style> -- Gitblit v1.9.3