便利贴--22{Avue表格自定义以及适应高度}

该博客介绍了如何在Vue项目中使用Avue组件库时,实现表格高度自适应以及全局监听屏幕尺寸变化。通过监听窗口大小并结合Avue的样式调整,确保表格在不同屏幕尺寸下保持良好显示效果。内容涉及到Vue页面的watch备份,以及如何处理由于Avue封装导致的初次高度设置问题。

store-只需要给自己的表格加上class

<avue-crud
class=“tablesss”
这加上class

// import {getStore, setStore} from '@/util/store'

// import {getDictionary} from '@/api/system/dict'
let screenSizes = {
   
   
  w: window.screen.width,
  h: window.screen.height
};
let innerWH = {
   
   
  innerWidth: window.innerWidth,
  innerHeight: window.innerHeight
};
const control = {
   
   
  state: {
   
   
    clearOtherBut: {
   
   
      refreshBtn: false,
      columnBtn: false,
      searchShowBtn: false,
      filterBtn: false,
      addBtn: false,
      editBtn: false,
      viewBtn: false,
      delBtn: false,
      searchIndex: 6, //收缩展示数量
      searchIcon: true, //搜索是否收缩
      height: window.screen.height //初始高度
    },
    changePageSize: {
   
   
      pageSize: 15,
      currentPage: 1,
      total: 0,
      pageSizes: [15, 30, 50, 100]
    },
    windowWidth: innerWH.innerWidth,
    windowHeight: innerWH.innerHeight,
    tableWindowHeight: innerWH.innerHeight,
    heightTimesOut: "",
    table_height: "",
    butState: "",
    oldOpens: "",
    screenSize: screenSizes.w <= 1366 && screenSizes.h <= 768,
    screenHeight: 1000,

    searchOpen: {
   
   
      searchIndex: 6, //收缩展示数量
      searchIcon: true, //搜索是否收缩
      height: window.screen.height //初始高度
    }
  },
  actions: {
   
   
    WHchangeHight({
    
    
      state,
      commit
    }, data) {
   
   
      if (data.fn) {
   
   
        if (!state.heightTimesOut) {
   
   
          data.fn(state.windowHeight);
        } else {
   
   
          state.heightTimesOut = setTimeout(() => {
   
   
            clearTimeout(state.heightTimesOut);
            state.heightTimesOut = "";
            data.fn(state.windowHeight);
          }, 500);
        }
      }
    },

    TABLE_CHANGEBUTPOSITION({
    
    
      state,
      commit,
      dispatch
    }, data) {
   
   
      let table = document.getElementsByClassName("tablesss")[0];
      let heard = table.getElementsByClassName("avue-crud__search")[0]; //获取搜索的长度
      let buts = table.getElementsByClassName("avue-form__menu--center")[0];
      let Open = buts.getElementsByClassName("el-button--text")[0];
      let butsheight = heard.clientHeight;
      let other = data.otherclass || [];
      // buts.style.transition = "all 0.1s";
      if (buts) {
   
   
        buts.style.top = butsheight - 3 + "px";
      }
      if (other && state.windowWidth >= 1024) {
   
   
        for (let k in other) {
   
   
          let otherbuts = document.getElementsByClassName(other[k])[0];
          // otherbuts.style.transition = "all 0.1s";
          if (otherbuts) {
   
   
            otherbuts.style.top = butsheight + 26 + "px";
          }
        }
      }
      // Open.style.transition = "all 0.1s";
      // Open.style.top = -(butsheight + 4) + "px";
      // 添加事件
      if (Open) {
   
   
        Open.style.top = (state
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

轻动琴弦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值