当前位置:网站首页>How do I listen for changes in DOM element size?
How do I listen for changes in DOM element size?
2022-06-21 08:43:00 【huangpb0624】
Ideas :
window Yes resize event , We can think of it iframe Also have resize event . We're listening for dimensional changes DOM Add a iframe,iframe Set up width、height All for 100%, And bind the resize Events can be monitored .
Code implementation :
<template>
<div class="container">
<div class="item" :style="{height}">
<iframe ref="iframe" class="iframe"></iframe>
</div>
<button @click="changeHeight"> Change the height </button>
</div>
</template>
<script>
export default {
data() {
return {
height: '200px'
}
},
mounted () {
this.$refs.iframe?.contentWindow.addEventListener('resize', () => {
console.log('resize')
});
},
methods: {
changeHeight() {
this.height = '300px';
}
},
};
</script>
<style scoped>
.item {
position: relative;
width: 200px;
border: 1px solid #ccc;
}
.iframe {
position: absolute;
z-index: -1000;
width: 100%;
height: 100%;
border: none;
opacity: 0;
}
</style>边栏推荐
- 关于sql的问题:两张表的字段关联问题
- Abstractqueuedsynchronizer (AQS) source code detailed analysis - lock competitive resource analysis
- Base de données de sauvegarde DumpLiNg
- PS prompts "script error -50 general Photoshop error, how to solve it?
- STL教程3-类型转换static_cast、dynamic_cast、const_cast、reinterpret_cast方法
- Unmanned, automation technology affects the world
- Dumpling備份數據庫
- WordPress media library supports uploading and previewing SVG icons
- Figure out how MySQL works
- JUnit中的@Transactional消失不见,@Rollback是否能单抗测试回滚的大旗?
猜你喜欢

Detailed analysis of ThreadPoolExecutor source code of thread pool

GQL+Nodejs+MySQL数据库

优化食品生产行业库存管理的6种方法

Mono fourni avec l'unit é 5 peut également supporter C # 6

Classic topics of leetcode array (I)
![[Mgt] model Mgt for code interpretation](/img/4f/694e7b93626436007021b718ad69b5.png)
[Mgt] model Mgt for code interpretation

Two image enhancement methods: image point operation and image graying

Fd: file descriptor

leetcode:19. 删除链表的倒数第 N 个结点

Can you implement these requirements with MySQL
随机推荐
The way of filling holes in APK Decompilation
Ads Filter Design Wizard tool 2
Character function and string function
写文章的markdown规则
【C】【时间操作】C语言中关于时间的操作
安装MySQL出现白页面怎么办
26. Hikvision camera configuration and preliminary test
Talking about Festinger effect
南京理工大学MOOC慕课:程序设计基础(Ⅰ)第8章测试选择题答案及解析
SQL to check the disk usage of the database / table, kill the process and terminate the connection in tidb
apk 反编译 上的填坑之路
sql查看数据库/表磁盘占用情况,杀死进程终止tidb中的连接
5分钟搞懂MySQL - 行转列
The difference between tuples and lists
MySQL filter query (start with a letter, start with a number, start without a number, and start without a letter)
Adapt to the pits in Huawei models
GQL+Nodejs+MySQL数据库
Abstractqueuedsynchronizer (AQS) source code detailed analysis - countdownlatch source code analysis
Windows10 LAN shared folder process
基于Retrotfit2.1+Material Design+ijkplayer开发的一个APP