All Projects → john015 → vue-load-image

john015 / vue-load-image

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

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to vue-load-image

vitepress-for-component
📖 针对组件开发的VitePress。
Stars: ✭ 142 (+136.67%)
Mutual labels:  vue-components, vue3
Nutui
京东风格的移动端 Vue2、Vue3 组件库 (A Vue.js UI Toolkit for Mobile Web)
Stars: ✭ 3,870 (+6350%)
Mutual labels:  vue-components, vue3
smart-tagz
🏷Smart input tags for Vue
Stars: ✭ 28 (-53.33%)
Mutual labels:  vue-components, vue3
vue2-timeago
🙌 A vue component used to format date with time ago statement. 💬
Stars: ✭ 76 (+26.67%)
Mutual labels:  vue-components, vue3
Vue Content Placeholders
Composable components for rendering fake (progressive) content like facebook in vue
Stars: ✭ 1,547 (+2478.33%)
Mutual labels:  loader, vue-components
hoc-element-table
📦 A Vue 3.x Table Component built on Webpack 5
Stars: ✭ 26 (-56.67%)
Mutual labels:  vue-components, vue3
codemirror-editor-vue3
CodeMirror component for Vue3
Stars: ✭ 22 (-63.33%)
Mutual labels:  vue-components, vue3
fect
Minimalist UI components built on Vue-next
Stars: ✭ 352 (+486.67%)
Mutual labels:  vue-components, vue3
Vue Spinners
💫 A collection of loading spinner components for Vuejs
Stars: ✭ 255 (+325%)
Mutual labels:  loader, vue-components
vue-skeleton-loader
A simple and easily customizable skeleton loader plugin for you Vue application.
Stars: ✭ 74 (+23.33%)
Mutual labels:  loader, vue-components
vuestic-ui
Free and Open Source UI Library for Vue 3 🤘
Stars: ✭ 1,501 (+2401.67%)
Mutual labels:  vue-components, vue3
Vue Wait
Complex Loader and Progress Management for Vue/Vuex and Nuxt Applications
Stars: ✭ 1,869 (+3015%)
Mutual labels:  loader, vue-components
Vuc
🎨 基于 Vuejs2 的 Canvas 组件库【服务器挂了。不在提供demo,github自带的静态网站不能发布,因为demo代码找不到了😂。】
Stars: ✭ 52 (-13.33%)
Mutual labels:  vue-components, vue-image
v-pip
🖼 Tiny vue wrapper for supporting native picture-in-picture mode.
Stars: ✭ 30 (-50%)
Mutual labels:  vue-components, vue3
v-intl
Add i18n to your awesome Vue 3 app 🔉
Stars: ✭ 13 (-78.33%)
Mutual labels:  vue-components, vue3
vui-vc-next
Vue 3 with Vite Playground - Mobile web UI components - (vue3+vite2).
Stars: ✭ 15 (-75%)
Mutual labels:  vue-components, vue3
vue-cirrus
Vue components for the Cirrus CSS framework.
Stars: ✭ 43 (-28.33%)
Mutual labels:  vue-components, vue3
vue3-docs
vue中文社区,vue3 中文文档
Stars: ✭ 180 (+200%)
Mutual labels:  vue-components, vue3
Vue3 News
🔥 Find the latest breaking Vue3、Vue CLI 3+ & Vite News. (2021)
Stars: ✭ 2,416 (+3926.67%)
Mutual labels:  vue-components, vue3
Vue Loaders
Vue + loaders.css
Stars: ✭ 127 (+111.67%)
Mutual labels:  loader, vue-components

English | 한국어

Vue-load-image

npm npm bundle size (minified) npm version NpmLicense

Vue-load-image is 1KB(gzipped size) minimalist Vue component that display loader during image loading and display alternate content when the image fails to load.

Demo

vue-load-image Demo / (Source Code)

Installation

Via NPM:

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

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

Via CDN:

<!-- for Vue 2.x -->
<script src='https://unpkg.com/vue-load-image'></script>

<!-- for Vue 3.x -->
<script src='https://unpkg.com/vue-load-image@next'></script>

Usage

Image

Vue 2.x

<template>
  <div>
    <vue-load-image>
      <img slot="image" src="./image.png"/>
      <img slot="preloader" src="./image-loader.gif"/>
      <div slot="error">error message</div>
    </vue-load-image>
  </div>
</template>

<script>
import VueLoadImage from 'vue-load-image'

export default {
  components: {
    'vue-load-image': VueLoadImage
  }
}
</script>

Vue 3.x

<template>
  <div>
    <vue-load-image>
      <template v-slot:image>
        <img src="./image.png"/>
      </template>
      <template v-slot:preloader> 
        <img src="./image-loader.gif" />
      </template>
      <template v-slot:error>Image load fails</template>
    </vue-load-image>
  </div>
</template>

<script>
import VueLoadImage from 'vue-load-image'

export default {
  components: {
    'vue-load-image': VueLoadImage
  }
}
</script>

Background-image

Vue 2.x

<template>
  <div>
    <vue-load-image>
      <div slot="image" style="background-image: url(./image.png)" data-src='./image.png' />
      <img slot="preloader" src="./image-loader.gif" />
      <div slot="error">error message</div>
    </vue-load-image>
  </div>
</template>

<script>
import VueLoadImage from 'vue-load-image'

export default {
  components: {
    'vue-load-image': VueLoadImage
  }
}
</script>

Vue 3.x

<template>
  <div>
    <vue-load-image>
      <template v-slot:image>
        <div style="background-image: url(./image.png)" data-src='./image.png' />
      </template>
      <template v-slot:preloader> 
        <img src="./image-loader.gif" />
      </template>
      <template v-slot:error>Image load fails</template>
    </vue-load-image>
  </div>
</template>

<script>
import VueLoadImage from 'vue-load-image'

export default {
  components: {
    'vue-load-image': VueLoadImage
  }
}
</script>

⚠️Notice

Set data-src to be the same as background-image url

Events

Name Description
onError onError gets triggered when the image fails to load.
onLoad onLoad gets triggered when the image is loaded.

Slots

"image" slot will be rendered when the image is successfully loaded

"preloader" slot will be rendered when the image is in the process of loading

"error" slot will be rendered when the image load fails.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].