vue动态修改div、table...元素高度宽度
根据浏览器宽高度,动态显示内容的宽高,总体就是给设置宽高的对象设置一个监听器即可<template><el-container style="height: 100%;width: 100%;">...</el-container></template><script>export default {data() {return {...
·
根据浏览器宽高度,动态显示内容的宽高,总体就是给设置宽高的对象设置一个监听器即可
<template>
<el-container style="height: 100%;width: 100%;">
...
</el-container>
</template>
<script>
export default {
data() {
return {
...
}
},
created() {
// 创建监听和监听对象即可
window.addEventListener('resize', this.setTableHeight)
// this.setTableHeight()
},
destroy() {
window.removeEventListener('resize', this.setTableHeight)
},
methods: {
setTableHeight() {
this.$nextTick(() => {
this.statisticsTableHeight = (window.innerHeight - 100 - 36 * 2) / 2
this.entityFrom.tableHeight = window.innerHeight-360 })
}
}
}
</script>
<style scoped lang="scss">
</style>
更多推荐
已为社区贡献4条内容
所有评论(0)