0.1.8 • Published 3 years ago

image-looker v0.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

image-looker

A PC side enlarge preview picture component, based on react.

How to use

Install package:

npm install --save image-looker

Import to your app:

import { ImageLooker } from "image-looker";

Use the component:

使用此组件包裹住多个<img/> 标签或者单个<img/> 标签,并像下面这样给这些<img/> 添加属性:

export default class App extends React.Component {
  const imgs = [{
    src: '/xxx.jpg',
    thumbnail: '/xxx_w100_h200.jpg',
    status: 'done'
  }, {
    src: '/yyy.jpg',
    thumbnail: '/yyy_w100_h200.jpg',
    status: 'fail'
  }];
  render() {
    return (
      <ImageLooker className="container">
        {imgs.map(img => {
          return (
            <img
              src={img.thumbnail}
              data-src={img.src}
              data-invalid={img.status === 'fail'}
            />
          )
        })}
      </ImageLooker>
    );
  }
}

API

<img/> 需要的额外属性

API 名称用法是否必填
data-src放大展示时使用的高清原图地址否,不填默认使用 src
data-invalid当前图片是否禁用大图预览,一般图片加载失败等情况可以使用此属性否,不填默认不禁用
0.1.8

3 years ago

0.1.7

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago