단추를 누르면 대응하는div로 미끄러집니다

1460 단어



export default {
    data(){
        return{
            showIndex:null
        }
    },
    methods: {
        showDetails(num){
            var el=document.getElementsByClassName(`listshow${num}`)[0];
            console.log(el.offsetTop);
            if(this.showIndex==num){
                this.showIndex=null;
            }else{
                this.showIndex=num;
            }
            this.$nextTick(function () {
                window.scrollTo({"behavior":"smooth","top":el.offsetTop});
            })
        }
    }
}





좋은 웹페이지 즐겨찾기