//设置scrollBehavior无效
scrollBehavior: (to, from, savedPosition) => ({
x: 0,
y: 0
})
//包裹路由出口的盒子加ref
<section class="sectionBox" ref="app">
<div class="bread-crumb" v-html="crumbsValue"></div>
<router-view />
</section>
watch: {
$route(to, from) {
let main = this.$refs.app;
main.scrollTo(0, 0);
},
},