VUE solves the anchor refresh problem

VUE solves the anchor refresh problem

  // 子页面
  // 子页面按钮

<div style="padding-top: 20px;">
   <el-button type="danger" @click="jumpConsole3">Started</el-button>
  </div>

 // 调用父页面方法
methods: {
    
    
   jumpConsole3() {
    
    
      this.$parent.selfFun()
   }
 }
  // 父页面
  // 父页面锚点
  <a name="firstAnchor" id="firstAnchor"></a>

  // 父页面方法
    methods: {
    
    
    selfFun() {
    
    
      document.querySelector('#firstAnchor').scrollIntoView(true)
    },
}

Guess you like

Origin blog.csdn.net/weixin_45563734/article/details/122184987