primevue-mirror/doc/passthrough/LifecycleDoc.vue

75 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: {
2023-09-22 12:54:14 +00:00
basic: `
<Panel header="Header" :pt="panelPT">
2023-07-09 21:13:49 +00:00
Content
2023-10-15 09:38:39 +00:00
</Panel>
`,
2023-09-22 12:54:14 +00:00
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
}
}
}
}
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
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
}
}
);
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-07-09 21:13:49 +00:00
}
};
}
};
</script>