An open API service indexing awesome lists of open source software.

https://github.com/john015/vue-load-image

A Vue component for showing loader during image loading https://john015.github.io/vue-load-image/
https://github.com/john015/vue-load-image

image image-loader image-preloader loader vue vue-components vue-image vue-image-loader vue-load-image vue3 vue3-image-loader vuejs

Last synced: 3 months ago
JSON representation

A Vue component for showing loader during image loading https://john015.github.io/vue-load-image/

Awesome Lists containing this project

README

          

[English](./README.md) | ν•œκ΅­μ–΄

# vue-load-image

[![npm](https://img.shields.io/npm/dt/vue-load-image.svg)](https://www.npmjs.com/package/vue-load-image) ![npm bundle size (minified)](https://img.shields.io/bundlephobia/minzip/vue-load-image.svg) [![npm version](https://img.shields.io/npm/v/vue-load-image.svg?style=flat)](https://www.npmjs.com/package/vue-load-image) [![NpmLicense](https://img.shields.io/npm/l/vue-load-image.svg)](https://github.com/john015/vue-load-image/blob/master/LICENSE)

vue-load-image λŠ” μ΄λ―Έμ§€λ‘œλ“œ 쀑 이미지 λ‘œλ”λ₯Ό ν‘œμ‹œν•˜λ©° μ΄λ―Έμ§€λ‘œλ“œμ— μ‹€νŒ¨ ν–ˆμ„λ•Œ λŒ€μ²΄ λ‚΄μš©μ„ ν‘œμ‹œν•˜λŠ” 1KB(gzipped size) Vue component μž…λ‹ˆλ‹€.

## Demo

[vue-load-image Demo](https://john015.github.io/vue-load-image/) / [(Source Code)](https://github.com/john015/vue-load-image/tree/master/example)

## Installation

### Via NPM:

```bash
# for Vue 2.x
npm i vue-load-image

# for Vue 3.x
npm i vue-load-image@next
```

### Via CDN:

```html

```

## Usage

### Image

#### Vue 2.x

```js





error message


import VueLoadImage from 'vue-load-image'

export default {
components: {
'vue-load-image': VueLoadImage
}
}

```

#### Vue 3.x

```js









Image load fails

import VueLoadImage from 'vue-load-image'

export default {
components: {
'vue-load-image': VueLoadImage
}
}

```

### Background-image

#### Vue 2.x

```js





error message


import VueLoadImage from 'vue-load-image'

export default {
components: {
'vue-load-image': VueLoadImage
}
}

```

#### Vue 3.x

```js









Image load fails

import VueLoadImage from 'vue-load-image'

export default {
components: {
'vue-load-image': VueLoadImage
}
}

```

#### βš οΈμœ μ˜μ‚¬ν•­

data-src 값을 background-image url κ³Ό λ™μΌν•˜κ²Œ μ„€μ • ν•΄μ£Όμ„Έμš”.

## Events

| Name | Description |
| --------- | ------------------------------------------ |
| `onError` | 이미지 λ‘œλ“œ μ‹€νŒ¨μ‹œ onError κ°€ 호좜 λ©λ‹ˆλ‹€. |
| `onLoad` | 이미지가 λ‘œλ“œλ˜λ©΄ onLoad κ°€ 호좜 λ©λ‹ˆλ‹€. |

## Slots

이미지가 μ„±κ³΅μ μœΌλ‘œ λ‘œλ“œ 되면 "image" slot 이 λ Œλ”λ§ λ©λ‹ˆλ‹€.

이미지가 λ‘œλ“œ 쀑일 λ•Œ "preloader" slot 이 λ Œλ”λ§λ©λ‹ˆλ‹€.

μ΄λ―Έμ§€λ‘œλ“œμ— μ‹€νŒ¨ν•˜λ©΄ "error" slot 이 λ Œλ”λ§λ©λ‹ˆλ‹€.