primevue-mirror/doc/dynamicdialog/DialogServiceDoc.vue

45 lines
1.4 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
2023-11-02 06:28:24 +00:00
<p>A single shared dialog instance is required in the application, ideal location would be defining it once at the main application template.</p>
<DocSectionCode :code="code1" hideToggleCode hideCodeSandbox hideStackBlitz />
<p>A dynamic dialog is controlled via the <i>DialogService</i> that needs to be installed as an application plugin.</p>
<DocSectionCode :code="code2" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>The service is available with the <i>useDialog</i> function for Composition API or using the <i>$dialog</i> property of the application for Options API.</p>
<DocSectionCode :code="code3" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
2023-02-28 08:29:30 +00:00
</DocSectionText>
</template>
<script>
export default {
data() {
return {
2023-03-08 08:35:24 +00:00
code1: {
2023-09-22 12:54:14 +00:00
basic: `
2023-11-02 06:28:24 +00:00
<DynamicDialog />
`
},
code2: {
basic: `
2023-09-22 12:54:14 +00:00
import {createApp} from 'vue';
2023-02-28 08:29:30 +00:00
import DialogService from 'primevue/dialogservice';
const app = createApp(App);
2023-09-26 12:14:16 +00:00
app.use(DialogService);
`
2023-03-08 08:35:24 +00:00
},
2023-11-02 06:28:24 +00:00
code3: {
2023-09-22 12:54:14 +00:00
basic: `
2023-11-02 06:28:24 +00:00
/* Composition API */
2023-09-22 12:54:14 +00:00
import { useDialog } from 'primevue/usedialog';
2023-03-08 08:35:24 +00:00
2023-09-26 12:14:16 +00:00
const dialog = useDialog();
2023-10-15 09:38:39 +00:00
2023-11-02 06:28:24 +00:00
/* Options API */
const dialog = this.$dialog;
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>