uniapp div随滚动背景渐变

uniapp yekong 147℃

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>

js


    onPageScroll(res) {
        this.top = res.scrollTop;
    },
    
    computed: {
        // 计算属性的 getter
        bg: function() {
            // `this` 指向 vm 实例
            return 'rgba(255,255,255, ' + this.top / 20 + ')';
        },

        isshow: function() {
            if (this.top > 20) {
                return false;
            } else {
                return true;
            }
        }
    },
喜欢 (0)