搞了一天,才实现这个功能。vue项目,与jsp页面,代码的写法是不同的。
<el-row style="margin-top: 20px;">
<button class="linkWayBtn" @click="toTop">
<el-image src="/static/img/public/to_top.png"></el-image>
<div class="linkWayContent">回到顶部</div>
</button>
</el-row>
toTop(){
//这种方式,在vue项目,无效
this.KaTeX parse error: Expected 'EOF', got '}' at position 34: …ollIntoView(); }̲ 改成 toTop(){ …nextTick(() => {
this.$refs.container.scrollTop = 0;
});
}