<template>
<div id="demo">
<div>......</div>
<div ref="scrollDiv" :style="{ height: scrollHeight, overflow: 'scroll' }">
<div>.......</div>
</div>
</template>
<script>
export default {
name: "demo",
data() {
return {
scrollHeight: '300px',
};
},
async created() {
this.$nextTick(() => {
let rect = this.utiljs.isDom(this.$refs.scrollDiv) ? this.$refs.scrollDiv.getBoundingClientRect() : this.$refs.scrollDiv[0].getBoundingClientRect();
let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
this.scrollHeight = (clientHeight - rect.top - 10) + 'px';// 这里避免padding、margin造成误差,适当缩小10px
})
},
methods: {
},
};
</script>
12-01
4142
06-11
07-27
291