当前位置: 首页 > news >正文

037:vue项目监听页面变化,动态设置iframe元素高度

在这里插入图片描述

第037个

查看专栏目录: VUE ------ element UI


专栏目标

在vue和element UI联合技术栈的操控下,本专栏提供行之有效的源代码示例和信息点介绍,做到灵活运用。

(1)提供vue2的一些基本操作:安装、引用,模板使用,computed,watch,生命周期(beforeCreate,created,beforeMount,mounted, beforeUpdate,updated, beforeDestroy,destroyed,activated,deactivated,errorCaptured,components,)、 $root , $parent , $children , $slots , $refs , props, $emit , eventbus ,provide / inject, Vue.observable, $listeners, $attrs, $nextTick , v-for, v-if, v-else,v-else-if,v-on,v-pre,v-cloak,v-once,v-model, v-html, v-text, keep-alive,slot-scope, filters, v-bind,.stop, .native, directives,mixin,render,国际化,Vue Router等

(2)提供element UI的经典操作:安装,引用,国际化,el-row,el-col,el-button,el-link,el-radio,el-checkbox ,el-input,el-select, el-cascader, el-input-number, el-switch,el-slider, el-time-picker, el-date-picker, el-upload, el-rate, el-color-picker, el-transfer, el-form, el-table, el-tree, el-pagination,el-badge,el-avatar,el-skeleton, el-empty, el-descriptions, el-result, el-statistic, el-alert, v-loading, $message, $alert, $prompt, $confirm , $notify, el-breadcrumb, el-page-header,el-tabs ,el-dropdown,el-steps,el-dialog, el-tooltip, el-popover, el-popconfirm, el-card, el-carousel, el-collapse, el-timeline, el-divider, el-calendar, el-image, el-backtop,v-infinite-scroll, el-drawer等

本文章目录

    • 专栏目标
    • 需求背景
    • 示例效果
    • 示例源代码(共57行)

需求背景

在vue项目开发中,有时候需要用到iframe。而iframe要正常显示,需要设定width和height。这里的示例是通过watch监听页面变化,可以动态的设置iframe元素高度。

示例效果

在这里插入图片描述

示例源代码(共57行)

/*
* @Author: 大剑师兰特(xiaozhuanlan),还是大剑师兰特(CSDN)
* @此源代码版权归大剑师兰特所有,可供学习或商业项目中借鉴,未经授权,不得重复地发表到博客、论坛,问答,git等公共空间或网站中。
* @Email: 2909222303@qq.com
* @weixin: gis-dajianshi
* @First published in CSDN
* @First published time: 2022-09-21
*/
<template><div class="container"><iframe width="100%" :height="fullHeight" :src="urlSRC" ></iframe> </div>
</template>
<script>export default {data() {return {urlSRC:'http://www.cuclife.com/',fullHeight: document.documentElement.clientHeight , timer: true }},methods: {},mounted(){window.onresize = () => { return (() => { window.fullHeight = document.documentElement.clientHeight; this.fullHeight = window.fullHeight ; })(); }; },watch: { fullHeight(val) { console.log(val)if (!this.timer) {//防止多次触发监听页面卡顿 this.fullHeight = val; this.timer = true; let that = this; setTimeout(function() { that.timer = false; }, 400); } } }, }
</script>
<style scoped>.container {width: 100%;height: 100vh;}</style>
http://www.lryc.cn/news/171880.html

相关文章:

  • 探索前端生成二维码技术:简单实用的实现方式
  • python装13的一些写法
  • 黑马JVM总结(十八)
  • Android调用相机拍照,展示拍摄的图片
  • 企业如何找媒体发稿能收录且不被拒稿,媒介盒子无偿分享
  • 利用cms主题构造木马(CVE-2022-26965)
  • 【MTK】【WFD】手机投屏到投影仪不显示画面
  • 多输入多输出 | MATLAB实现PSO-LSSVM粒子群优化最小二乘支持向量机多输入多输出
  • scrapyd-完整细节
  • 【iOS逆向与安全】插件开发之某音App直播间自动发666
  • AI Studio星河社区生产力实践:基于文心一言快速搭建知识库问答
  • http1和http2的主要区别
  • 一文了解水雨情在线监测站的优势
  • windows11中安装curl
  • 小谈设计模式(5)—开放封闭原则
  • 计算机视觉与深度学习-全连接神经网络-训练过程-欠拟合、过拟合和Dropout- [北邮鲁鹏]
  • SwiftUI Swift iOS iPadOS 实现更改 App 图标
  • Java————List
  • uniapp 触底加载
  • 大模型赛道如何实现华丽的弯道超车
  • CAN总线物理层
  • 中兴面试-Java开发
  • 浅谈 React 与 Vue 更新机制的差异
  • Delft3D水动力与泥沙运动模拟实践技术应用
  • Linux 本地Yearning SQL 审核平台远程访问
  • Redis集群(Cluster)
  • Scapy 解析 pcap 文件从HTTP流量中提取图片
  • 难得有个冷静的程序员发言了:纯编码开发实施的项目,失败的案例也有很多
  • Leetcode.146 LRU 缓存
  • 科技资讯|Canalys发布全球可穿戴腕带设备报告,智能可穿戴增长将持续