[TOC]
## 1.設置滾動
```
mounted() {
window.addEventListener("scroll", this.handleScroll);
});
```
## 2. 清除滾動
```
destroyed() {
window.removeEventListener("scroll", this.handleScroll);
},
```
## 3.設置滾動具體效果
> isNav 是設置的滾動觸發的效果
```
handleScroll() {
var top = document.documentElement.scrollTop || document.body.scrollTop;
if (top > 0) {
this.isNav = true;
var opacity = top / 200;
if (opacity > 1) {
opacity = 1;
}
this.opacitys.opacity = opacity;
} else {
this.isNav = false;
}
},
```