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

The height attribute of the [Bug Report] table component is invalid when it is a string #15986

Closed
luoshanmai opened this issue Jun 10, 2019 · 3 comments

Comments

@luoshanmai
Copy link

Element UI version

2.9.1

OS/Browsers version

Google Chrome 74.0.3729.169

Vue version

2.6.10

Reproduction Link

https://codepen.io/luoshanmai/pen/orvpod?&editable=true

Steps to reproduce

设置属性height="100%"

What is Expected?

页面上显示为style="height:100%;"

What is actually happening?

页面上显示为style="height:100px;"

@element-bot element-bot changed the title [Bug Report] table组件height属性为字符串时无效 The height attribute of the [Bug Report] table component is invalid when it is a string Jun 10, 2019
@element-bot
Copy link
Member

Translation of this issue:

Element UI version

2.9.1

OS/Browsers version

Google Chrome 74.0.3729.169

Vue version

2.6.10

Reproduction Link

Https://codepen.io/luoshanmai/pen/orvpod?&editable=true

Steps to reproduce

Set the attribute height= "100%"

What is Expected?

The page shows style = "height: 100%;"

What is actually happening?

The page shows style = "height: 100px;"

@jinghui70
Copy link

table/utils.js 173

export function parseHeight(height) {
  if (typeof height === 'number') {
    return height;
  }
  if (typeof height === 'string') {
    if (/^\d+(?:px)?/.test(height)) {
      return parseInt(height, 10);
    }
    console.warn('[Element Warn][ElTable]invalid height and it will be ignored.');
  }
  return null;
}

table-layout.js line 56:

setHeight(value, prop = 'height') {
    if (Vue.prototype.$isServer) return;
    const el = this.table.$el;
    value = parseHeight(value); // 100% turn into 100
    this.height = value;

    if (!el && (value || value === 0)) return Vue.nextTick(() => this.setHeight(value, prop));

    if (value) {
      el.style[prop] = `${value}px`; // style=height:100px
      this.updateElsHeight();
    }
  }

@ziyoung
Copy link
Contributor

ziyoung commented Jun 11, 2019

Duplicate of #15858

@ziyoung ziyoung marked this as a duplicate of #15858 Jun 11, 2019
@ziyoung ziyoung closed this as completed Jun 11, 2019
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

4 participants