我在页面上有一个内部链接:
<h3 id="report">Preview Report</h3>
当我提交表单时,我会调用如下所示的方法
methods: {
generateReport: function(link) {
console.log(link);
window.location.href = "report"
}
}
它不会向下滚动到页面内链接report
的位置,而是导航到其他页面(默认主页)
答案 0 :(得分:0)
<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()
}
}