vue图像识别_Vue的超级简单图像懒惰加载器

vue图像识别

多维数据集图像懒惰 (cube-vue-image-lazy)

A super simple image lazy loader for Vue.

Vue的超级简单图像懒惰加载器。

安装 (Install)

yarn add cube-vue-image-lazy

Warning: You'll need to install the w3c Intersection Observer polyfill in case you're targeting a browser which doesn't support it.

警告 :如果您要针对不支持它的浏览器,则需要安装w3c Intersection Observer polyfill

用法 (Usage)

You can register the component globally so it's available in all your apps:

您可以全局注册该组件,以便在所有应用程序中都可以使用它:

import Vue from 'vue'
import ImageLazy from 'cube-vue-image-lazy'

Vue.use(ImageLazy)

// Or you can override defaults
Vue.use(ImageLazy, {
  name: 'ImageLazyLoad',
  delay: 500,
  baseClass: 'image-lazy-load',
  deferredClass: 'image-lazy-load-deferred',
  loadingClass: 'image-lazy-load-loading',
  loadedClass: 'image-lazy-load-loaded'
})

Or use it locally in any of your components:

或在您的任何组件中本地使用它:

<template>
  <div id="App">
    <ImageLazy
      class="photo"
      src="https://source.unsplash.com/random/200x200"
      srcset="https://source.unsplash.com/random/400x400 2x"
      baseClass="image-lazy"
      deferredClass="image-lazy-deferred"
      loadingClass="image-lazy-loading"
      loadedClass="image-lazy-loaded"
      :delay="500"
      @loading="loading = true"
      @load="loaded = true"
    />
  </div>
</template>

<script>
import ImageLazy from 'cube-vue-image-lazy'

export default {
  components: {
    ImageLazy
  },
  data () {
    return {
      loading: false,
      loaded: false
    }
  }
}
</script>

<style>
.image-lazy {
  opacity: 0;
}
.image-lazy-loading {
  transform: translateX(100vh);
}
.image-lazy-loaded {
  transition: opacity 1s ease;
  opacity: 1;
}
</style>

道具 (Props)

NameRequiredTypeDefaultDescription
delayfalseNumber0The delay before loading the image when it appears in the viewport.
baseClassfalseString'image-lazy'The name of the class always added to the image.
deferredClassfalseString'image-lazy-deferred'The name of the class added while the loading of the image is deferred.
loadingClassfalseString'image-lazy-loading'The name of the class added while the image is loading.
loadedClassfalseString'image-lazy-loaded'The name of the class added when the image is loaded.
名称 需要 类型 默认 描述
延迟 0 当图像出现在视口中时,加载图像之前的延迟。
baseClass 图像懒惰 类的名称总是添加到图像中。
deferredClass “图像延迟延迟” 延迟图像加载时添加的类的名称。
loadingClass “图像延迟加载” 加载图像时添加的类的名称。
loadClass 图像懒加载 加载图像时添加的类的名称。

大事记 (Events)

NameDescription
loadingThe image is loading.
loadThe image is loaded.
名称 描述
装货 图像正在加载。
加载 图像已加载。

开发设置 (Development Setup)

# Project setup
yarn install

# Compiles and hot-reloads for development – Run the demo
yarn serve

# Compiles and minifies for production
yarn build

# Builds the npm ready packages
yarn bundle

# Watches for file changes and builds the npm ready packages accordingly
yarn watch

# Lints and fixes files
yarn lint

# Run the unit tests
yarn test:unit

翻译自: https://vuejsexamples.com/a-super-simple-image-lazy-loader-for-vue/

vue图像识别

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值