Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Table:表格新增最小高度min-height #1166

Open
hushengbin789 opened this issue Aug 16, 2024 · 0 comments
Open

Table:表格新增最小高度min-height #1166

hushengbin789 opened this issue Aug 16, 2024 · 0 comments

Comments

@hushengbin789
Copy link

Table表格新增最小高度min-height,方便使用最小高度
props: { minHeight: { type: [Number, String] } }
computed-->styles
styles () { let style = {}; if (this.height) { const height = parseInt(this.height); style.height =${height}px; } if (this.maxHeight) { const maxHeight = parseInt(this.maxHeight); style.maxHeight = ${maxHeight}px; } if (this.minHeight) { const minHeight = parseInt(this.minHeight); style.minHeight = ${minHeight}px; } if (this.width) style.width = ${this.width}px; return style; },
computed-->bodyStyle
bodyStyle () { let style = {}; if (this.bodyHeight !== 0) { const height = this.bodyHeight; if (this.height) { style.height =${height}px; } else if (this.maxHeight) { style.maxHeight = ${height}px; } else if (this.minHeight) { style.minHeight = ${height}px; } } return style; }
computed-->toggleExpand
`
toggleExpand (_index) {
let data = {};

            for (let i in this.objData) {
                if (parseInt(i) === _index) {
                    data = this.objData[i];
                    break;
                }
            }
            const status = !data._isExpanded;
            this.objData[_index]._isExpanded = status;
            this.$emit('on-expand', JSON.parse(JSON.stringify(this.cloneData[_index])), status);
            
            if(this.height || this.maxHeight || this.minHeight){
                this.$nextTick(()=>this.fixedBody());
            }
        }

computed-->fixedHeader
fixedHeader () {
if (this.height || this.maxHeight || this.minHeight) {
this.$nextTick(() => {
const titleHeight = parseInt(getStyle(this.$refs.title, 'height')) || 0;
const headerHeight = parseInt(getStyle(this.$refs.header, 'height')) || 0;
const footerHeight = parseInt(getStyle(this.$refs.footer, 'height')) || 0;
if (this.height) {
this.bodyHeight = this.height - titleHeight - headerHeight - footerHeight;
} else if (this.maxHeight) {
this.bodyHeight = this.maxHeight - titleHeight - headerHeight - footerHeight;
} else if (this.minHeight) {
this.bodyHeight = this.minHeight - titleHeight - headerHeight - footerHeight;
}
this.$nextTick(()=>this.fixedBody());
});
} else {
this.bodyHeight = 0;
this.$nextTick(()=>this.fixedBody());
}
}
watch-->minHeight
minHeight () {
this.handleResize();
},
`

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant