2023-11-02 06:28:24 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>The <i>emits</i> object defines callbacks to handle events emitted by the component within the Dialog.</p>
|
|
|
|
|
2024-01-30 08:16:35 +00:00
|
|
|
<DocSectionCode :code="code1" importCode hideToggleCode hideStackBlitz />
|
|
|
|
<DocSectionCode :code="code2" importCode hideToggleCode hideStackBlitz />
|
2023-11-02 06:28:24 +00:00
|
|
|
</DocSectionText>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code1: {
|
|
|
|
basic: `
|
|
|
|
import ProductListDemo from './ProductListDemo';
|
|
|
|
import { useDialog } from 'primevue/usedialog';
|
|
|
|
|
|
|
|
const dialog = useDialog();
|
|
|
|
|
|
|
|
const showProducts = () => {
|
|
|
|
dialog.open(ProductListDemo, {
|
|
|
|
onCancel: (e) => {
|
|
|
|
console.log(e); // {user: 'primetime'}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
`
|
|
|
|
},
|
|
|
|
code2: {
|
|
|
|
basic: `
|
|
|
|
<script setup>
|
|
|
|
/* ProductListDemo.vue */
|
2024-06-26 10:37:19 +00:00
|
|
|
const emit = defineEmits(['cancel', 'save'])
|
2023-11-02 06:28:24 +00:00
|
|
|
|
|
|
|
function buttonClick() {
|
2024-06-26 10:37:19 +00:00
|
|
|
emit('cancel', {user: 'primetime'});
|
2023-11-02 06:28:24 +00:00
|
|
|
}
|
|
|
|
<\/script>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|