You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VuePress中关闭页面切换过渡动画?

关闭vuepress-theme-hope页面切换动画的方法

方法一:通过主题配置直接关闭

你可以直接在主题配置文件(通常是.vuepress/config.ts或.vuepress/theme/config.ts)中添加对应配置项即可禁用全局切换动画:

import { defineUserConfig } from "vuepress";
import { hopeTheme } from "vuepress-theme-hope";

export default defineUserConfig({
  theme: hopeTheme({
    // 其他现有配置保持不变
    transition: {
      page: false,
      fade: false
    }
  })
})

如果是旧版本主题,若上述配置不生效,可尝试添加animation: false配置项:

export default defineUserConfig({
  theme: hopeTheme({
    animation: false
  })
})

方法二:CSS样式强制覆盖(兜底方案)

如果配置项不生效,可以在.vuepress/styles/index.scss中添加如下样式,强制禁用所有页面切换过渡效果:

/* 禁用页面切换动画 */
.page-enter-active,
.page-leave-active,
.layout-enter-active,
.layout-leave-active {
  transition: none !important;
}

.page-enter-from,
.page-leave-to,
.layout-enter-from,
.layout-leave-to {
  opacity: 1 !important;
}

配置完成后重新启动本地开发服务或者重新打包即可生效。

内容的提问来源于stack exchange,提问作者citykid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.11 17:06:01