vue加载js延迟
vue-tiny-lazyload-img (vue-tiny-lazyload-img)
A small size Vue.js v.2+ directive for lazy loading images.
一个小尺寸的Vue.js v.2 +指令,用于延迟加载图像。
用法 (Usage)
下载 (Download)
npm install vue-tiny-lazyload-img
安装插件 (Install Plugin)
import VueTinyLazyloadImg from 'vue-tiny-lazyload-img'
Vue.use(VueTinyLazyloadImg);
HTML片段 (HTML Snippet)
<img v-lazyload
src="./assets/logo.png"
data-src="./assets/logo-success.png"
data-err="./assets/logo-error.png">
请使用polyfill (Please Use polyfill)
This plugin using IntersectionObserver
, so please use polyfill if you need support old browser https://github.com/w3c/IntersectionObserver/tree/master/polyfill
该插件使用IntersectionObserver
,因此如果您需要支持旧版浏览器,请使用polyfill https://github.com/w3c/IntersectionObserver/tree/master/polyfill
构建设置 (Build Setup)
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production demo with minification
npm run build
# build for plugin distribution file
npm run pack
# run build and pack
npm run dist
翻译自: https://vuejsexamples.com/a-small-size-vue-js-v-2-directive-for-lazy-loading-images/
vue加载js延迟