首页 > 其他 > 详细

react图片自适应组件

时间:2019-07-23 14:57:41      阅读:281      评论:0      收藏:0      [点我收藏+]
import * as React from ‘react‘;
import ‘animate.css/animate.css‘
import {AutoImg} from "./style";
import {observer} from "mobx-react";
import {action} from "mobx";
import {IAd} from "../../util/type";

interface IIndexProps {
    url: string;
    row:boolean;
    width:number;
    height:number;
}

@observer
class Index extends React.Component<IIndexProps> {

    constructor(props) {
        super(props);
    }

    public render() {
        const {url,row,width,height} = this.props;
        return (
            <div style={{width:`${width}px`,height:`${height}px`,overflow: ‘hidden‘,display:‘flex‘,alignItems:‘center‘,justifyContent:‘center‘}}>
                {
                    row
                        ?
                        <img src={url} style={{width:‘auto‘,height:‘100%‘}} />
                        :
                        <img src={url} style={{width:‘100%‘,height:‘auto‘}} />
                }
            </div>
        );
    }
}

export default Index;

  

react图片自适应组件

原文:https://www.cnblogs.com/piaobodewu/p/11231749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!