primevue-mirror/doc/passthrough/LifecycleDoc.vue

72 lines
1.6 KiB
Vue
Raw Normal View History

2023-07-09 21:13:49 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>
2023-07-10 17:40:30 +00:00
Lifecycle hooks of components are exposed as pass through using the <i>hooks</i> property so that callback functions can be registered. Available callbacks are <i>onBeforeCreate</i>, <i>onCreated</i>, <i>onBeforeUpdate</i>,
<i>onUpdated</i>, <i>onBeforeMount</i>, <i>onMounted</i>, <i>onBeforeUnmount</i> and <i>onUnmounted</i>. Refer to the Vue.js documentation for detailed information about lifecycle hooks.
2023-07-09 21:13:49 +00:00
</p>
</DocSectionText>
<DocSectionCode :code="code" hideCodeSandbox hideStackBlitz />
</template>
<script>
export default {
data() {
return {
code: {
basic: `
2023-07-14 07:21:51 +00:00
<Panel header="Header" :pt="panelPT">
2023-07-09 21:13:49 +00:00
Content
</Panel>`,
options: `
<template>
2023-07-14 07:21:51 +00:00
<Panel header="Header" :pt="panelPT">
2023-07-09 21:13:49 +00:00
Content
</Panel>
</template>
<script>
export default {
data() {
return {
panelPT: {
hooks: {
2023-07-10 17:40:30 +00:00
onMounted: () => {
2023-07-09 21:13:49 +00:00
//panel mounted
},
2023-07-10 17:40:30 +00:00
onUnmounted: () => {
2023-07-09 21:13:49 +00:00
//panel unmounted
}
}
}
}
}
};
<\/script>`,
composition: `
<template>
2023-07-14 07:21:51 +00:00
<Panel header="Header" :pt="panelPT">
2023-07-09 21:13:49 +00:00
Content
</Panel>
</template>
<script setup>
import { ref } from 'vue';
const panelPt = ref({
hooks: {
2023-07-10 17:40:30 +00:00
onMounted: () => {
2023-07-09 21:13:49 +00:00
//panel mounted
},
2023-07-10 17:40:30 +00:00
onUnmounted: () => {
2023-07-09 21:13:49 +00:00
//panel unmounted
}
}
);
<\/script>`
}
};
}
};
</script>