关于在js里定义变量,然后在css里取用

.kanban_statusBar {
        height: calc(var(--maxStatusDescHeight) + 45px) ;
      }
// vue的methods里

// 动态设置 kanban_statusBar 与 kanban_order 的间距
    setStatusBarHeight() {
      var statusDesc = document.querySelectorAll(".kanban_statusBar > :nth-child(odd) :nth-child(2)");
      var statusDescHeight = [];
      statusDesc.forEach((item) => {
        statusDescHeight.push(item.clientHeight);
      });
      var maxStatusDescHeight = Math.max(...statusDescHeight);
      document.documentElement.style.setProperty("--maxStatusDescHeight", maxStatusDescHeight + "px");
    },

posted @ 2024-06-20 09:25  茫茫人间刺骨凉  阅读(18)  评论(0)    收藏  举报