Socket
Socket
Sign inDemoInstall

mt-lazy-image

Package Overview
Dependencies
8
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mt-lazy-image

lazy image, is a react component that lazy image, build for mobile web app


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
3.39 MB
Created
Weekly downloads
 

Readme

Source

mt-lazy-image

A light-weight React mt-lazy-image component with extremely easy API(只适用于移动端项目). Online Demo, welcome code review

Installation

npm install mt-lazy-image --save

Usage mt-lazy-image

import React, { PureComponent } from 'react';
import './app.less';
import Image from 'mt-lazy-image'
import { data } from './constant';

export default class App extends PureComponent {
  constructor() {
    super();
    this.state = {
      source: [],
    }
    this.containRef = React.createRef(null);
  }

  componentDidMount() {
    this.setState({ source: data })
  }

  render() {
    return (
      <div className="container" >
        <ul className="mt-goods-list" ref={this.containRef}>
          {
            this.state.source.map(item =>
              <li className="mt-goods-list-item" key={item.goods_id}>
                <Image
                  src={item.url}
                  alt="商品图片"
                  className="mt-goods-list-item-avator"
                  container={this.containRef.current}
                />
                <div className="mt-goods-list-item-name">{item.name}</div>
                <div className="mt-goods-list-item-price">{(item.price / 100 || 0).toFixed(2)}</div>
                <div className="mt-goods-list-item-button">去抢购</div>
              </li>
            )
          }
        </ul>
      </div>
    );
  }
}

props

paramdetailtypedefault
classNameimg class namestring''
srcimg srcstringisRequired
defaultsrcimg default srcstring''
altimg altstring''
containerUnder which DOM node (overflow: auto / scroll)anywindow
propNameOther HTML attributes that can be set on the img elementany

注意

使用是需要注意 container props。这个props的值是一个设置了 overflow: auto | scroll 属性的 dom 元素

Keywords

FAQs

Last updated on 18 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc