For the complete documentation index, see llms.txt. This page is also available as Markdown.

NavigationBar.setOptions

功能说明

会更改导航栏的返回、首页、标题显示、透明与否、背景色、图标·文字主题。只会应用传入的字段,省略的字段会保持上一次应用的值。首次调用前的值是小程序 config 的 navigationBar。

transparentBackground当 true时,导航栏会叠加在内容之上,不占据布局高度。此时 backgroundColor不适用。 backgroundColor在 null时,返回主题默认背景色。 theme只会更改图标·文字颜色。

类型

参数

type NavigationBarTheme = "light" | "dark";

interface SetNavigationBarOptions {
  withBackButton?: boolean;
  withHomeButton?: boolean;
  withTitle?: boolean;
  transparentBackground?: boolean;
  backgroundColor?: string | null; // `#RRGGBB` 或 `#RRGGBBAA`
  theme?: NavigationBarTheme;
}

返回值

Promise<void>;

示例代码

这有帮助吗?