您的位置:首页 > 科技 > 能源 > 公众号入口_网络商城排名_推广策略及推广方式_电脑培训速成班多少钱

公众号入口_网络商城排名_推广策略及推广方式_电脑培训速成班多少钱

2025/10/3 2:55:57 来源:https://blog.csdn.net/mm_0123456789/article/details/146803737  浏览:    关键词:公众号入口_网络商城排名_推广策略及推广方式_电脑培训速成班多少钱
公众号入口_网络商城排名_推广策略及推广方式_电脑培训速成班多少钱

表格高度自适应

文章目录

  • 表格高度自适应
      • 1、方法一
      • 2、方法二


1、方法一

根据页面元素计算各自占比

<template><div class="main"><div class="query-form" ref="Query"><QueryFormref="QueryForm"@query="query"></QueryForm></div><div class="table-box" ref="Temp"><TableModalref="TableModal":maxHeight="tempHeight-200":tableData="tableData"></TableModal><!-- 分页 --><div class="pagination-box flex-h flex-he"><el-pagination@size-change="handleSizeChange"@current-change="handleCurrentChange":page-sizes="pageSizes":current-page="pageNum":page-size="pageSize":total="total"layout="total, sizes, prev, pager, next, jumper"backgroundsmall></el-pagination></div></div></div>
</template><script>import QueryForm from './QueryForm.vue';import TableModal from './TableModal.vue';import FileSaver from "file-saver";export default {components: {QueryForm, TableModal,},data() {return {tableData: [],total: 0,pageNum: 1,pageSize: 10,pageSizes: [10, 20, 50, 100],multipleSelection: [],maxHeight: 220,windowHeight: 0,  // 页面窗口高度tempHeight: 0,  // 元素高度QueryHeight: 0, // 查询框高度}},mounted() {this.query()// 自动获取元素高度var that = this;//刚进入页面时,获取窗口默认宽高度this.windowHeight = document.body.clientHeightthis.QueryHeight = this.$refs.Query.offsetHeight//进入页面元素默认宽高// this.tempHeight = this.$refs.Temp.offsetHeight// this.maxHeight = this.tempHeight - 70this.tempHeight = this.windowHeight - this.QueryHeightwindow.onresize = () => {return (() => {//窗口缩放自动获取页面宽高window.fullHeight = document.documentElement.clientHeight;this.QueryHeight = this.$refs.Query.offsetHeightthat.windowHeight = window.fullHeight; //高//窗口缩放自动获取元素宽高// this.tempHeight = this.$refs.Temp.offsetHeight //高// this.maxHeight = this.tempHeight - 70this.tempHeight = this.windowHeight - this.QueryHeight})()}},methods: {// 分页handleSizeChange (val) {this.pageSize = valthis.query()},// 当前页handleCurrentChange (val) {this.pageNum = valthis.query()},handleSelectionChange(val) {this.multipleSelection = val},query(){const form = this.$refs.QueryForm.getParams()const params = { ...form, pageNum: this.pageNum, pageSize: this.pageSize}// ....},  },}
</script><style lang="scss" scoped>
.main  {padding: 10px;background-color: #F2F3F5;
} // 分页
.pagination-box {margin-top: 20px;float: right;
}
:deep .pagination-box .el-select--mini .el-input--mini .el-input__inner {height: 22px;line-height: 22px;
}:deep .pagination-box .el-select--mini .el-input--mini .el-input__icon {line-height: 22px;
}
</style>

2、方法二

直接计算表格高度

<template><div><el-card><QueryFormref="queryForm"@query="query"></QueryForm></el-card><TableColumn:tableData="tableData":tableHeight="tableHeight"></TableColumn></div></template><script>
import QueryForm from "./queryForm.vue"
import TableColumn from './tableColumn.vue'export default {components: {QueryForm,TableColumn,},data() {return {tableData: [],tableHeight: 0,}},created() {this.tableHeight = window.innerHeight - 340},mounted() {this.query()this.handleTableHeight()},methods: {handleTableHeight: function () {var _this = this;window.onresize = () => {_this.tableHeight = window.innerHeight - 346};},query() {const params = this.$refs.queryForm.getForm()// .......},}
}
</script><style lang="less" scoped >.el-card {margin: 0 0 10px 0;}
</style>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com