how can I change background-color of navbar when scrolling event with Vuejs. I tried V-scroll event by using this answer How to change css while scrolling in Vue this is the code but it does not work?
<nav v-scroll="handleScroll">
<div class="logo">
<img src="../assets/images/logo.png" alt="logo" />
<button id="mobBtn" @click="displayList">
<i class="fas fa-bars"></i>
</button>
</div>
<ul class="navlist" id="mobList">
<li>
<a href>Home</a>
</li>
<li>
<a href>About</a>
</li>
<li>
<a href>Blog</a>
</li>
<li>
<a href>Contact</a>
</li>
</ul>
</nav>
<script>
export default {
name: "Header",
data: {},
methods: {
handleScroll: function (evt, el) {
alert("Dddd")
if (window.scrollY > 50) {
el.setAttribute(
'style',
'background-color: red;'
)
}
return window.scrollY > 100
}
};
</script>