Skip to content

SelectTitleBar

下拉菜单标题栏包含一个下拉菜单,可用于页面之间的切换;可用于一级页面、二级及其以上界面(配置返回键)。

效果

导入模块

js
import { promptAction, SelectTitleBar } from "@kit.ArkUI";

子组件

参数

options

数组类型,里面参数如下 value 文字,icon 图标

js

[
  { value: '所有照片', icon: $r('sys.media.ohos_save_button_filled') },
  { value: '本地(设备)' },
  { value: '本地本地本地本地本地(储存卡)' }
],

selected

number 类型 初始选择第一个下拉选项, 从 0 开始

onSelected

选中的时候触发的回调函数

js
  // 选中时触发函数
onSelected: (index) => promptAction.showToast({ message: 'page index ' + index }),

hidesBackButton

true 就是隐藏,false 就是显示

隐藏左侧返回箭头

subtitle

副标题

右边的图标合集

  • isEnabled 是否可用

  • value 图标

  • action 点击后的事件

js

menuItems: [{
    isEnabled: true, value: $r('sys.media.ohos_save_button_filled'),
    action: () => promptAction.showToast({ message: 'show toast index 1' }),
}],

属性

事件

示例

js
SelectTitleBar({
  // 定义下拉列表选项
  options: [
    { value: "所有照片" },
    { value: "本地(设备)" },
    { value: "本地本地本地本地本地(储存卡)" },
  ],
  // 初始选择第一个下拉选项
  selected: 0,
  // 选中时触发函数
  onSelected: (index) =>
    promptAction.showToast({ message: "page index " + index }),
  // 隐藏左侧返回箭头
  hidesBackButton: true,
  // 副标题
  subtitle: "example@example.com",
  // 右侧图标
  menuItems: [
    {
      isEnabled: true,
      value: $r("sys.media.ohos_save_button_filled"),
      action: () => promptAction.showToast({ message: "show toast index 1" }),
    },
  ],
});