primevue-mirror/apps/showcase/doc/dynamicdialog/EventsDoc.vue

46 lines
1.0 KiB
Vue
Raw Normal View History

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 */
const emit = defineEmits(['onCancel', 'onSave'])
function buttonClick() {
2023-11-15 17:26:40 +00:00
emit('onCancel', {user: 'primetime'});
2023-11-02 06:28:24 +00:00
}
<\/script>
`
}
};
}
};
</script>