应用场景:顶部展示图片时,导航栏透明显示;当滚动页面时,导航栏不再透明显示。
1、div
<div class="topback" v-if="isshow">
<div class="back"><uni-icons color="#fcfcfc" @click="goback" type="arrowleft" size="30"></uni-icons></div>
</div>
<div class="daohang1" v-if="!isshow" :style="{ background: bg }">
<div class="back"><uni-icons color="#999999" @click="goback" type="arrowleft" size="30"></uni-icons></div>
<div class="titlex">#{{ data.name }}#</div>
</div>
2、js
onPageScroll(res) {
this.top = res.scrollTop;
},
computed: {
bg: function() {
return 'rgba(255,255,255, ' + this.top / 20 + ')';
},
isshow: function() {
if (this.top > 20) {
return false;
} else {
return true;
}
}
},