primevue-mirror/doc/dynamicdialog/OpenDialogDoc.vue

43 lines
1.2 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>The <i>open</i> function of the <i>DialogService</i> is used to open a Dialog. First parameter is the component to load and second one is the configuration object to customize the Dialog.</p>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code1" importCode hideToggleCode hideStackBlitz />
2023-11-02 06:28:24 +00:00
<p>The component can also be loaded asynchronously, this approach is useful in conditional cases and to improve initial load times as well.</p>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code2" importCode hideToggleCode hideStackBlitz />
2023-02-28 08:29:30 +00:00
</DocSectionText>
</template>
<script>
export default {
data() {
return {
2023-11-02 06:28:24 +00:00
code1: {
2023-09-22 12:54:14 +00:00
basic: `
import ProductListDemo from './ProductListDemo';
2023-11-02 06:28:24 +00:00
import { useDialog } from 'primevue/usedialog';
2023-02-28 08:29:30 +00:00
2023-11-02 06:28:24 +00:00
const dialog = useDialog();
2023-02-28 08:29:30 +00:00
2023-11-02 06:28:24 +00:00
const showProducts = () => {
dialog.open(ProductListDemo, {});
2023-10-15 09:38:39 +00:00
}
2023-11-02 06:28:24 +00:00
`
},
code2: {
basic: `
2023-02-28 08:29:30 +00:00
import { useDialog } from 'primevue/usedialog';
2023-11-02 06:28:24 +00:00
const dialog = useDialog();
const dynamicComponent = defineAsyncComponent(() => import('./ProductListDemo.vue'));
2023-02-28 08:29:30 +00:00
const showProducts = () => {
2023-11-02 06:28:24 +00:00
dialog.open(dynamicComponent, {});
}
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>