惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - 彭成刚

Service workers 缓存导致 3000端口占用 解决方案 Unregister - FossFLOW iview table 单行显示文字 默认key 文字超出宽度 显示... 加tip cut-text2.vue configQueryListFunc.js 命令行合并图片成为pdf `magick *.jpg o.pdf` vue2 自动格式化 函数名和括号直接没有空格了 eslint爆红,解决方案,函数名+空格+() vscode 设置 flex gap 对老版本浏览器兼容 - "flex-gap-polyfill": "^1.0.4", 老版 对 vue2 iview 打包失败的解决方案 [软件推荐] 手机同步电脑 PandaControl 开发安卓app 截屏用的 Multi-Layer Perceptron.xlsx 讲明白ai底层本质 pdfjs-3.11.174-legacy-dist.zip 最后一个cdn版本,每次要升级pdfjs 都是这个坑,中间件不支持mjs,但是国产化那个老浏览器媲美ie6 做了一个卷子去底的程序 python-clear-paper [ai问答] js对象 某个属性找到父节点 __parent__ 一键注入函数 buildTreeRelations [精品] npm 内网离线安装包 从缓存本地安装, .tgz安装失败时候,用这个cache方案 三次贝塞尔曲线 一直想要一个 曲线箭头,先AI出个代码先存着。 http-server-o.bat 最方便启动当前目录的index.html [记录] 多文件上传BUG解决记录-选择文件后-修改本地文件名-点击上传失败 的解决过程 vscode 查看全局包函数源码 没安装插件 - 快速跳转第三方库的函数源码 - 在资源管理器视图中显示 自定义快捷键 Alt+Shift+Z vscode vue2项目 自定义 abc类型 自动提示 3种提示方式 分别是 abc this.abc window.abc vscode 提交 github 的 git提交 记得设置 proxy - 基础知识 阻止连点小函数 if(islock()) return vue 双向绑定 对象初始化 不替换指针 用 Object.assign(app.value.modalAddWan, $app.modalAddWan) lunacy 单机离线免费 ui设计工具 平替 figma sketch [工具推荐] 双击最大化 软件右边留出一些空白 MaxMax 软件推荐 [推荐] GLM-4.7 智谱 Agentic Coding AI开发 环境安装 vibe coding 鼠标有小圈圈在转,原因是安全中心在扫描你的程序,关闭扫描方案 右下角广告 查看pid 映射是哪个程序弹框 Process Explorer 我发现我就是太善良了,总愿意相信有免费的api(AI) 软件推荐:Beyond.Compare.v3.3.13.18981 文本对比软件 临时忽略 config.js git命令 node_modules 软连接 win11 mklink /D 两个项目共享一个库 需求:两个分支,两套代码同时修改 iview table 排序 columns 里面写 sortable: 'custom' 不要写 sortable: true 不然会进行二次内部排序序号等 字段。 vue2 重置 data方法 $data $options.data.call(this) vue中 先写 函数调用 再写 函数定义的 小技巧 function caller () {} copy-used-css 代码段 snippet,将指定节点的计算样式获取下拉 获取tailwind网页样式成原生样式 Syntax Error: TypeError: eslint.CLIEngine is not a constructor 解决方案 Comment Anchors [vscode插件推荐] 注释跳转 ANCHOR[id=锚点] LINK path/file.vue#锚点 写了一个undefind 的bug ['',null,undefined].includes(unName) 应该是 typeof unName === 'undefined' pad开发bug vscode 左侧栏 显示隐藏 ctrl+b 查看:切换主侧栏可见性 View: Toggle Primary Side Bar Visibility
vue2 hooks useInnerHeight.vue 解决Table高度实时更新
彭成刚 · 2025-08-26 · via 博客园 - 彭成刚

vue2 hooks useInnerHeight.vue 解决Table高度实时更新

背景

iview Table组件 有一个height的属性,为了实现浏览器改变,需要高度实时变化

useInnerHeight.vue

/src/hooks/useInnerHeight.vue

<template>
  <span style="display: hidden;"></span>
</template>

<script>
export default {
  components: {},
  props: {
    value: Number
  },
  data () {
    return {
      innerHeight: window.innerHeight,
    }
  },
  watch: {},
  computed: {
  },
  methods: {
    resizeHeight() {
      this.$emit('input', window.innerHeight)
    },
  },
  created () { },
  activated () { },
  mounted () { 
    window.addEventListener("resize", this.resizeHeight);
  },
  beforeDestroy () { 
    window.removeEventListener("resize", this.resizeHeight);
  }
}
</script>

<style lang="less" scoped>
</style>

app.vue

<template>
  <div id="app" style="width: 100%; height: 100%;">
    <useInnerHeight v-model="innerHeight"/>
  </div>
</template>

<script>
import useInnerHeight from '@/hooks/useInnerHeight'
export default {
  name: 'App',
  components: { useInnerHeight },
  data () {
    return {
      innerHeight: window.innerHeight,
    }
  },
  computed: {
  },
  created () {
    Vue.prototype.$app = this
  },
  methods: {
  },
  mounted () {
  },
  destroyed () {
  }
}
</script>
<style scoped lang="less">
</style>

业务页面.vue

<template>
   <div class="container-table mt10">
      <Table
        :height="tableHeight"
      >
    </Table>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data () {
    return {
    }
  },
  watch: {},
  computed: {
    tableHeight() {
      return this.$app.innerHeight - 180 - 40;
    },
  },
  methods: {
  },
  created () { },
  activated () { },
  mounted () {
   },
  beforeDestroy () { 
  }
}
</script>
<style lang="less" scoped>
</style>

使用的两种方法

  1. 全局使用,上面的用法就是全局使用,因为很多页面都会用到实时的innerHeight,所以就挂到了全局
  2. 局部使用,有的是业务代码,可以直接在业务页面使用。在页面创建一个变量,绑定到组件上。就不需要挂到全局使用了。