任何方法来控制VueRouter平滑滚动速度?



我可以实现smooth-scrollrouter-links:

<router-link :to="{ hash: 'home' }">Home</router-link>
<router-link :to="{ hash: 'about' }">About</router-link>

router.js:

import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../vue/home";
import About from "../vue/about";
Vue.use(VueRouter);
export default new VueRouter ({
mode: "history",
routes: [
{path: "/", name: "home", component: Home},
{path: "/about", name: "about", component: About},
],
scrollBehavior(to, from,  savedPosition) {
return {
selector: to.hash,
behavior: 'smooth'
}
}
});

vue'sv-smooth-scroll类相比,smooth-scroll类的效果稍慢。有没有办法控制VueRoutersmooth-scroll速度?

No.

Vue路由器的平滑滚动在实现本地浏览器APIScrollToOptions.behavior。这是由客户端的浏览器控制的。这可能因系统而异。

相关内容

  • 没有找到相关文章

最新更新