primevue-mirror/doc/orderlist/BasicDoc.vue

100 lines
2.6 KiB
Vue

<template>
<DocSectionText v-bind="$attrs">
<p>OrderList requires an array as its value bound with the <i>v-model</i> directive and <i>item</i> template for its content.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<OrderList v-model="products" dataKey="id" breakpoint="1400px" pt:pcList:root="w-full md:w-14rem">
<template #item="{ item }">
{{ item.name }}
</template>
</OrderList>
</div>
<DocSectionCode :code="code" v-bind="$attrs" :service="['ProductService']" />
</template>
<script>
import { ProductService } from '@/service/ProductService';
export default {
data() {
return {
products: null,
code: {
basic: `
<OrderList v-model="products" dataKey="id" breakpoint="1400px" pt:pcList:root="w-full md:w-14rem">
<template #item="{ item }">
{{ item.name }}
</template>
</OrderList>
`,
options: `
<template>
<div class="card lg:flex lg:justify-content-center">
<OrderList v-model="products" dataKey="id" breakpoint="1400px" pt:pcList:root="w-full md:w-14rem">
<template #item="{ item }">
{{ item.name }}
</template>
</OrderList>
</div>
</template>
<script>
import { ProductService } from '@/service/ProductService'
export default {
data() {
return {
products: null
}
},
mounted() {
ProductService.getProductsSmall().then((data) => (this.products = data));
}
};
<\/script>
`,
composition: `
<template>
<div class="card lg:flex lg:justify-content-center">
<OrderList v-model="products" dataKey="id" breakpoint="1400px" pt:pcList:root="w-full md:w-14rem">
<template #item="{ item }">
{{ item.name }}
</template>
</OrderList>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ProductService } from '@/service/ProductService'
const products = ref(null);
onMounted(() => {
ProductService.getProductsSmall().then((data) => (products.value = data));
});
<\/script>
`,
data: `
/* ProductService */
{
id: '1000',
code: 'f230fh0g3',
name: 'Bamboo Watch',
description: 'Product Description',
image: 'bamboo-watch.jpg',
price: 65,
category: 'Accessories',
quantity: 24,
inventoryStatus: 'INSTOCK',
rating: 5
},
...`
}
};
},
mounted() {
ProductService.getProductsSmall().then((data) => (this.products = data));
}
};
</script>