Lazy-render 懒加载

支持内容延迟加载的组件

效果

使用方法

<template>
<div class="lc-demo">

<lc-title title="懒加载"></lc-title>
<category title="懒加载"></category>

<lc-lazy-render :time="time1">
<div class="lazy">
<img src="https://dqloa7ej5.lightyy.com/images/lightui/p1.png" class="lazy" style="width:25px;height:25px;"/>
</div>
</lc-lazy-render>

<lc-lazy-render :time="time2" @loaded="onLoad" :tip="tip" :tipStyle="tipStyle">
<div class="lazy">
<span class="lazy">11111</span>
</div>
</lc-lazy-render>

</div>
</template>

<script>
import LcTitle from '_mods/title.vue';
import Category from '_mods/category.vue';
export default {
components: { LcTitle, Category },
data(){
return {
time1:1000,
time2:3000,
tip:'加载中',
tipStyle:{'color':'red'}
}
},
methods: {
onLoad(){
console.log("加载了")
}
}
};
</script>
<style scoped>
.lazy-load{display: flex; justify-content: center;}
.lazy{margin-top:25px;display: flex; align-items: center;}
</style>

可配置参数

Prop Type Required Default Description
tip String N 正在渲染,请稍候 提示文本
time Number N 10 延迟加载时间(ms)
tipStyle Object N - 提示文字样式

事件回调

@loaded="onLoad" 组件加载完成后的事件