Using the beforeUnmount
lifecycle hook to create an alert with text taken from inside a <p>
element.
<script>
export default {
beforeUnmount() {
alert("beforeUnmount: The text inside the p-tag is: " + this.$refs.pEl.innerHTML);
}
}
</script>
Run Example »
The beforeUnmount
lifecycle hook happens right before the component is removed from the DOM.
When running code in the beforeUnmount
hook, the component is still fully functional.
Vue Tutorial: Vue Lifecycle Hooks
Vue Tutorial: The 'beforeUnmount' Hook
Vue Reference: Vue 'mounted' Lifecycle Hook
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!