react圖片自適應組件


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%'}} alt=""/>
                        :
                        <img src={url} style={{width:'100%',height:'auto'}} alt=""/>
                }
            </div>
        );
    }
}

export default Index;

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM