Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么要设定height为400px? #18

Open
QiuShuiDyp opened this issue Oct 20, 2022 · 0 comments
Open

为什么要设定height为400px? #18

QiuShuiDyp opened this issue Oct 20, 2022 · 0 comments

Comments

@QiuShuiDyp
Copy link

QiuShuiDyp commented Oct 20, 2022

环境说明

element-ui 2.x
el-table-infinite-scroll: "2.0.0"

问题描述

你好,代码中的这段没理解,为啥一定要设定height,强制设定height为400px,导致在行数少的应用场景下,有一个固定的高度,是否为破坏性变更?为啥不能是maxHeight?

if (!el.style.height) {
        scrollElem.style.height = '400px';
        // eslint-disable-next-line
        console.warn(
          `${msgTitle} el-table height required, otherwise will set default value: 400px`
        );
      }

建议

其次是指令能否对外暴露一个参数,用来处理动态绑定该指令的场景,毕竟该指令适用于数据量大的场景,一两条记录时不需要绑定该指令,从而避免副作用的影响。

inserted(el, binding, VNode, oldVNode) {
    // 补充的代码
    if(!binding.isBind) return 

    const scrollElem: HTMLElement = el.querySelector(elTableScrollWrapperClass);

    if (!scrollElem) {
      throw new Error(
        `${msgTitle}${elTableScrollWrapperClass} element not found.`
      );
    }

    scrollElem.style.overflowY = 'auto';

    // after render
    setTimeout(() => {
      if (!el.style.height) {
        scrollElem.style.height = '400px';
        // eslint-disable-next-line
        console.warn(
          `${msgTitle} el-table height required, otherwise will set default value: 400px`
        );
      }

      syncOptions(el, scrollElem);

      // use `InfiniteScroll`
      InfiniteScroll.inserted(scrollElem, binding, VNode, oldVNode);

      // used by unbind, destroy listener events
      el[elScope] = scrollElem[elScope];
    }, 0);
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant