Skip to content

Sidebar

基础用法

html

<pa-sidebar v-model="active">
  <pa-sidebar-item v-for="item in 3" :key="item" :title="`标签名${item}`" />
</pa-sidebar>
ts

import { ref } from 'vue'

const active = ref(0)

徽标提示

html

<pa-sidebar v-model="active">
  <pa-sidebar-item title="标签名" dot />
  <pa-sidebar-item title="标签名" badge="9" />
  <pa-sidebar-item title="标签名" badge="99+" />
</pa-sidebar>
ts

import { ref } from 'vue'

const active = ref(0)

禁用选项

html

<pa-sidebar v-model="active">
  <pa-sidebar-item
    v-for="item in 3"
    :key="item"
    :title="`标签名${item}`"
    :disabled="item === 2"
  />
</pa-sidebar>
ts

import { ref } from 'vue'

const active = ref(0)

切换事件

html

<pa-sidebar v-model="active" @change="onChange">
  <pa-sidebar-item title="标签名" />
  <pa-sidebar-item title="标签名" />
  <pa-sidebar-item title="标签名" />
</pa-sidebar>
ts

import { ref } from 'vue'
import type { SidebarValue } from '../..'

const active = ref(0)

const onChange = (value: SidebarValue) => {
  uni.showToast({
    icon: 'none',
    title: `你切换的值是 ${value}`,
  })
}
参数说明类型默认值
modelValue选择项值SidebarValue-
customClass根节点样式类string-
customStyle根节点样式string|CSSProperties-

SidebarItem Props

参数说明类型默认值
title标题string-
name当前项标识值SidebarValue-
dot是否展示为小点boolean-
badge图标右上角徽标的内容string-
disabled是否禁用该项boolean-
customClass根节点样式类string-
customStyle根节点样式string|CSSProperties-
事件名参数
update:modelValue(value: SidebarValue)
change(value: SidebarValue)

SidebarItem Event

事件名参数
click(value: SidebarValue)
名称说明
default-

SidebarItem Slot

名称说明
title-
after-

样式变量

名称默认值
--pa-sidebar-width80px