2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>DeferredContent is used by wrapping the target.</p>
|
|
|
|
</DocSectionText>
|
|
|
|
<div class="card">
|
|
|
|
<div style="height: 800px">Scroll down to lazy load an image.</div>
|
|
|
|
|
|
|
|
<DeferredContent @load="onImageLoad">
|
|
|
|
<img src="https://primefaces.org/cdn/primevue/images/nature/nature4.jpg" alt="Nature" />
|
|
|
|
</DeferredContent>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<DeferredContent @load="onImageLoad">
|
2023-02-28 08:29:30 +00:00
|
|
|
<img src="/images/nature/nature4.jpg" alt="Nature" />
|
2023-10-15 09:38:39 +00:00
|
|
|
</DeferredContent>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<Toast />
|
|
|
|
<div style="height: 800px">Scroll down to lazy load an image.</div>
|
|
|
|
|
|
|
|
<DeferredContent @load="onImageLoad">
|
|
|
|
<img src="https://primefaces.org/cdn/primevue/images/nature/nature4.jpg" alt="Nature" />
|
|
|
|
</DeferredContent>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
onImageLoad() {
|
|
|
|
this.$toast.add({ severity: 'success', summary: 'Image Initialized', detail: 'Scroll down to load the datatable', life: 2000 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<Toast />
|
|
|
|
<div style="height: 800px">Scroll down to lazy load an image.</div>
|
|
|
|
|
|
|
|
<DeferredContent @load="onImageLoad">
|
|
|
|
<img src="https://primefaces.org/cdn/primevue/images/nature/nature4.jpg" alt="Nature" />
|
|
|
|
</DeferredContent>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
|
const onImageLoad = () => {
|
|
|
|
toast.add({ severity: 'success', summary: 'Image Initialized', detail: 'Scroll down to load the datatable', life: 2000 });
|
|
|
|
};
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onImageLoad() {
|
|
|
|
this.$toast.add({ severity: 'success', summary: 'Success', detail: 'Image loaded', life: 2000 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|