有以下组件:
<template>
<div class="header">
Header content
</div>
</template>
<script>
export default {
}
</script>
<style>
.header {
position: fixed;
top: 0;
left: 0;
height: 100px;
width: 100%;
}
</style>
问题:如果滚动高度> 200px header-hidden
,如何添加类?div.header
在 vue 中挂起处理程序的最佳位置在哪里window.on
?当元素被销毁时,它们是否需要被销毁?
为了正确操作,处理程序最好放在块
mounted
或created
.destroyed
它应该从块中删除。