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

ins做甜品网站网络推广seo公司

ins做甜品网站,网络推广seo公司,汕头网站优化找谁,网站建设中 很快回来解决方法 在页面table上添加id,动态计算每页table的最大高度 ,将高度保存在store中,每次切换路由时进行计算。 文章目录 解决方法前言一、页面table使用二、store状态库1.引入库 效果 前言 提示:状态管理使用的是pinia,用法参考…

解决方法

在页面table上添加id,动态计算每页table的最大高度 ,将高度保存在store中,每次切换路由时进行计算。

文章目录

  • 解决方法
  • 前言
  • 一、页面table使用
  • 二、store状态库
    • 1.引入库
  • 效果

前言

提示:状态管理使用的是pinia,用法参考简单学习pinia

  1. 项目目录
    在这里插入图片描述

一、页面table使用

  1. 添加:max-height,和id
<el-table :max-height="tableHeightStore.height" id="elTableId" ><el-table-column type="selection" width="30" align="center" /><el-table-column label="标题" fixed align="center" prop="title" width="180" />
</el-table>
  1. js部分,引入高度tableHeightStore.height,计算高度方法useTableHeightStore().setTableHeight()
<script setup name="Activity">import useTableHeightStore from '@/store/modules/table'const tableHeightStore = useTableHeightStore()onActivated(() => {useTableHeightStore().setTableHeight()})onMounted(() => {useTableHeightStore().setTableHeight()})
</script>

二、store状态库

1.引入库

代码如下(table.js):

const useTableHeightStore = defineStore('table-height',{state: () => ({height: 500,//默认高度}),getters:{},actions:{setHeight(height) {this.height=height//高度赋值},setTableHeight() {//计算高度:窗口高度-表格距离顶部距离-固定高度(底部页码高度)this.height= window.innerHeight -document.getElementById("elTableId").getBoundingClientRect().top - 52;//问题:在浏览器窗口缩放90%时,table表的滚动条会消失(max-height丢失),解决:操作dom添加document.querySelector('#elTableId .el-scrollbar__wrap').style.maxHeight = this.height - 40 + "px"console.log("路由切换table高度刷新",this.height);window.onresize = () => {console.log("-----","防抖");debounce(tableHeightFun, 200); //防抖};let that=thisfunction tableHeightFun() {//页面没有table的id时,不执行if(document.getElementById('elTableId')==null)return//问题:在路由切换后,窗口高度变高,table表的max-height不能变大。解决:先赋值变小,再变大。that.height = window.innerHeight - document.getElementById('elTableId').getBoundingClientRect().top - 52 - 1;document.querySelector('#elTableId .el-scrollbar__wrap').style.maxHeight = (that.height - 40 - 1) + "px"setTimeout(() => {that.height=  window.innerHeight -document.getElementById("elTableId").getBoundingClientRect().top -52;document.querySelector('#elTableId .el-scrollbar__wrap').style.maxHeight = (that.height - 40) + "px"console.log("--tableHeightFun---",that.height);}, 200);}var timeout = null; //定义一个定时器function debounce(fn, wait) {if (timeout !== null) clearTimeout(timeout); //清除这个定时器timeout = setTimeout(fn, wait);}}}
})export default useTableHeightStore// table添加
// :max-height="tableHeightStore.height" id="elTableId"// 页面引入
// import useTableHeightStore from '@/store/modules/table'
// const tableHeightStore = useTableHeightStore()// 路由状态-缓存-每次进入页面触发onActivated
// onActivated(() => {
//   useTableHeightStore().setTableHeight()
// })// 路由状态-不缓存-每次进入页面触发onMounted
// onMounted(() => {
//   useTableHeightStore().setTableHeight()
// })

效果

在这里插入图片描述

http://www.shuangfujiaoyu.com/news/37072.html

相关文章:

  • 网站做支付宝 微信模块网络营销的基本方法有哪些
  • 怎么看网站有没有做301跳转搜索排名
  • 陕西百度公司seo是搜索引擎营销
  • 公司网站设计的企业网络营销包括几个部分
  • wordpress跨域登录seo外包公司一般费用是多少
  • c web网站开发vs2015视频讲解ai智能搜索引擎
  • 山东济南公厕seo关键词排名优化评价
  • 怎么做网站收录品牌广告和效果广告的区别
  • 银川网站建设哪家好电子商务网站建设论文
  • 自己做的网站标题app安装下载
  • 上海专业的网站建设公司排名抖音搜索优化
  • wordpress怎么加动态背景图图片长沙官网seo收费标准
  • 提供网站建设公司报价查询收录
  • vr 全景 网站建设学电子商务出来能干嘛
  • 宝鸡有做网站的吗广州王牌seo
  • 做赌博网站的代理算赌博罪吗企业网站优化技巧
  • 知名网站建设定制信息流广告公司一级代理
  • 网站开发论文研究内容百度资源平台
  • jsp网站开发步骤关键帧
  • 幼儿园微信网站怎么做网络运营是什么专业
  • 做电商网站的设计思路有什么意思搜索引擎seo优化
  • 帮人做违法网站人工在线客服系统
  • 浏览器的网站通知怎么做自建网站
  • html5 网站模板下载厦门seo公司到1火星
  • 宜昌市建设工程质量监督站网站图片优化是什么意思
  • 成都网站设公司电商培训机构
  • 初学网站开发360免费建站
  • 网站设计和营销免费域名注册二级域名
  • 沈阳做网站一诚金网络专业淘宝指数查询工具
  • 网站备案抽查指数函数求导