primevue-mirror/apps/showcase/doc/inplace/LazyDoc.vue

114 lines
3.3 KiB
Vue
Raw Permalink Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
2024-05-25 14:14:15 +00:00
<p>The <i>open</i> event is used to initialize the content such as loading data in a lazy manner.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
<div class="card">
<Inplace @open="loadData">
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>
</div>
<DocSectionCode :code="code" :service="['ProductService']" />
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Inplace @open="loadData">
2023-02-28 08:29:30 +00:00
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
2023-10-15 09:38:39 +00:00
</Inplace>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-02-28 08:29:30 +00:00
<div class="card">
<Inplace @open="loadData">
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>
</div>
</template>
<script>
import {ProductService} from '@/service/ProductService';
export default {
data() {
return {
products: null
}
},
methods: {
loadData() {
2024-05-25 14:14:15 +00:00
ProductService.getProductsMini().then((data) => (this.products = data));
2023-02-28 08:29:30 +00:00
}
}
}
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">
<Inplace @open="loadData">
<template #display> View Data </template>
<template #content>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
</DataTable>
</template>
</Inplace>
</div>
</template>
<script setup>
import { ref } from "vue";
import {ProductService} from "@/service/ProductService";
const products = ref();
const loadData = () => {
2024-05-25 14:14:15 +00:00
ProductService.getProductsMini().then((data) => (products.value = data));
2023-02-28 08:29:30 +00:00
}
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
loadData() {
2024-05-25 14:14:15 +00:00
ProductService.getProductsMini().then((data) => (this.products = data));
2023-02-28 08:29:30 +00:00
}
}
};
</script>