代码之家  ›  专栏  ›  技术社区  ›  Ciasto piekarz

如何通过按钮导航到页内链接单击vuejs表单

  •  0
  • Ciasto piekarz  · 技术社区  · 6 年前

    我在网页上有一个内部链接:

    <h3 id="report">Preview Report</h3>
    

    当我提交表单时,我调用如下所示的方法

    methods: {
            generateReport: function(link) {
                console.log(link);
                window.location.href = "report"
            }
    
        }
    

    而不是向下滚动到页面内链接的位置 report 是否导航到其他页面(默认主页)

    1 回复  |  直到 6 年前
        1
  •  0
  •   Sainath S.R    6 年前
    <h3 id="report" ref="report-link">Preview Report</h3>
    
    
    methods: {
            generateReport: function(link) {
                console.log(link);
                $ref['report-link'].scrollIntoView()
                 //or if you are receiving the link element dom itself as the param //just use
                link.scrollIntoView()
    
    
            }
    
        }