鍍金池/ 問答/HTML/ 點(diǎn)擊按鈕,使頁面滾動固定值

點(diǎn)擊按鈕,使頁面滾動固定值

電阻式觸屏設(shè)備上,因?yàn)榛瑒雍懿混`活,所以頁面上會設(shè)置按鈕來翻頁或者滑動頁面。

例如:可視區(qū)域A高度為500px,里面的內(nèi)容即可滾動區(qū)域B高度為1000px,然后有一個(gè)按鈕,點(diǎn)擊按鈕,B區(qū)域向下滾動200px,每點(diǎn)一下,都固定向下滾動200px,這個(gè)怎么實(shí)現(xiàn)呢?前提是這是用vue 寫的項(xiàng)目,沒有用jquery。

<template>
<div>
    <div class="wrapper" ref="apple">
        <div class="con"></div>
    </div>
    <button @click="handleClick">向下滑動</button>
</div>
</template>
export default {
    methods: {
        handleClick () {
            this.$refs.apple.scroll(0, 200)
        }
    }
}
.warpper {
    width: 500px;
    height: 500px;
    overflow-y: scroll;
}
.con {
    height: 1000px;
    width: 100%;
}
回答
編輯回答
尤禮
2017年6月20日 12:36
編輯回答
骨殘心

經(jīng)過測試,發(fā)現(xiàn) scrollBy() 這個(gè)方法可以滾動固定距離,例如:

this.$refs.apple.scrollBy(0, 200)
2017年9月19日 21:49