方法一:監聽滾動事件
$('.scrollContent').bind('touchmove', function(e){
var winHeight = $(window).scrollTop()
document.getElementById('opacityHeader').style.opacity=winHeight*0.01
document.getElementById('centerBg').style.opacity=1-winHeight*0.01
})
方法二:使用van-tab的scroll事件
van-tabs標簽內添加
@scroll='scroll'
methods內:
scroll(){
// debugger
let winHeight = $(window).scrollTop()
console.log(winHeight)
document.getElementById('漸變色div的id').style.opacity=winHeight*0.01
},