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

resize如何改变高度? #11

Closed
maoyr opened this issue Aug 23, 2016 · 1 comment
Closed

resize如何改变高度? #11

maoyr opened this issue Aug 23, 2016 · 1 comment

Comments

@maoyr
Copy link

maoyr commented Aug 23, 2016

elementResizeEvent(this.refs.echartsDom, function() {
            let div = document.getElementById(id),
                width =
 div.style.width|| div.clientWidth || div.offsetWidth || div.scrollWidth,
                height = width * 0.5;

            this.setState = {
                width:width,
                height:height
            }
            echartObj.resize();
        });
//-------------------------------------------------------------------
 render() {
        let  style = {width:this.state.width,height:this.state.height} || {height: '300px'};
        // for render
       return (
            <div id={this.state.id}
                 ref='echartsDom'
                 style={style}
                 />
        );
    }
//------------------------------------------------------------------

我想实现的效果是宽高比一定,高度随宽度变化而变化。
使用this.setState也没用,因为componentDidMount后不再render了。
请问这该怎么解决呀?

@hustcc
Copy link
Owner

hustcc commented Aug 23, 2016

传入style属性,或者设置classname,然后在css中设置高度…

@hustcc hustcc closed this as completed Aug 24, 2016
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

2 participants