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

Ionic Angular应用从CSR切换到SSR后ion-header样式丢失

Ionic Angular 切换为 SSR/SSG 后 ion-header 样式丢失

我给现有的CSR(客户端渲染)Ionic Angular网页应用(非Capacitor原生应用)添加SSR(服务端渲染)/SSG(静态站点生成)后,ion-header的样式不再正常显示:

添加SSR/SSG后的header样式

预期样式:

预期的header样式

组件代码如下:

<ion-header [translucent]="true">
  <ion-toolbar>
    <ion-title>
      Blank
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
  <ion-header collapse="condense">
    <ion-toolbar>
      <ion-title size="large">Blank</ion-title>
    </ion-toolbar>
  </ion-header>

  <div id="container">
    <strong>Ready to create an app?</strong>
    <p>Start with Ionic <a target="_blank" rel="noopener noreferrer" href="https://ionicframework.com/docs/components">UI Components</a></p>
  </div>
</ion-content>

发现一个特殊现象:只要在<ion-content>中添加一个简单的ion-button组件,整个header的样式就会恢复正常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.02 06:13:12