2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
2023-11-02 06:28:24 +00:00
|
|
|
<p>Use the <i>data</i> property to pass parameters when opening a Dialog, the internal component can later access this data using <i>dialogRef</i>.</p>
|
2023-02-28 08:29:30 +00:00
|
|
|
|
2023-03-13 13:31:27 +00:00
|
|
|
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
|
|
|
|
<DocSectionCode :code="code2" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
|
2023-02-28 08:29:30 +00:00
|
|
|
|
2023-11-02 06:28:24 +00:00
|
|
|
<p>Similarly when hiding a Dialog, any parameter passed to the <i>close</i> function is received from the <i>onClose</i> callback.</p>
|
2023-03-13 13:31:27 +00:00
|
|
|
<DocSectionCode :code="code3" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
|
|
|
|
<DocSectionCode :code="code4" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
|
2023-02-28 08:29:30 +00:00
|
|
|
</DocSectionText>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code1: {
|
|
|
|
basic: `
|
2023-11-02 06:28:24 +00:00
|
|
|
const dialog = useDialog();
|
|
|
|
|
|
|
|
const showProducts = () => {
|
|
|
|
dialog.open(ProductListDemo, {
|
|
|
|
data: {
|
|
|
|
user: 'primetime'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-09-26 12:14:16 +00:00
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
code2: {
|
2023-09-26 12:14:16 +00:00
|
|
|
basic: `
|
2023-11-02 06:28:24 +00:00
|
|
|
import { inject, onMounted } from "vue";
|
|
|
|
|
|
|
|
const dialogRef = inject('dialogRef');
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
const params = this.dialogRef.data; // {user: 'primetime'}
|
|
|
|
})
|
2023-09-26 12:14:16 +00:00
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
code3: {
|
|
|
|
basic: `
|
2023-11-02 06:28:24 +00:00
|
|
|
const dialog = useDialog();
|
|
|
|
|
|
|
|
const showProducts = () => {
|
|
|
|
dialog.open(ProductListDemo, {
|
|
|
|
onClose: (opt) => {
|
|
|
|
const callbackParams = opt.data; // {selectedId: 12}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-09-26 12:14:16 +00:00
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
},
|
|
|
|
code4: {
|
2023-09-26 12:14:16 +00:00
|
|
|
basic: `
|
2023-11-02 06:28:24 +00:00
|
|
|
import { inject } from "vue";
|
|
|
|
|
|
|
|
const dialogRef = inject('dialogRef');
|
|
|
|
|
|
|
|
const closeDialog = () => {
|
|
|
|
dialogRef.value.close({
|
|
|
|
selectedId: 12
|
|
|
|
});
|
2023-09-26 12:14:16 +00:00
|
|
|
}
|
|
|
|
`
|
2023-02-28 08:29:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|