Vue implements anchor scrolling reusability and function anti-shake

JS function anti-shake
anchor scrolling:

  • The parameter selector is the ID value of the target DOM
  • selectorNow is the real DOM node obtained according to the ID, the content is as shown in the figure below
goAnchor(selector) {
    
    
    let selectorNow =  this.$refs.wordcard[selector].$el;
    debugger
    selectorNow.scrollIntoView({
    
    
        behavior: "smooth",  // 平滑过渡
        block:    "start"  // 上边框与视窗顶部平齐。默认值
    });
},

insert image description here

おすすめ

転載: blog.csdn.net/Beatingworldline/article/details/121079479