Skip to content

Menu

基础用法

html

<pa-menu>
  <pa-menu-item v-model="state.value1" :options="state.option1"></pa-menu-item>
  <pa-menu-item v-model="state.value2" :options="state.option2"></pa-menu-item>
</pa-menu>
ts

import { reactive } from 'vue'

const state = reactive({
  option1: [
    { text: '全部商品', value: 0 },
    { text: '新款商品', value: 1 },
    { text: '活动商品', value: 2 },
  ],
  option2: [
    { text: '默认排序', value: 'a' },
    { text: '好评排序', value: 'b' },
    { text: '销量排序', value: 'c' },
  ],
  value1: 0,
  value2: 'a',
})

自定义菜单内容

html

<pa-menu>
  <pa-menu-item v-model="state.value1" :options="state.option1"></pa-menu-item>
  <pa-menu-item title="筛选">
    <pa-cell title="包邮">
      <pa-switch size="18px" />
    </pa-cell>
    <view class="px-16 py-10">
      <pa-button block round>确定</pa-button>
    </view>
  </pa-menu-item>
</pa-menu>
ts

import { reactive } from 'vue'

const state = reactive({
  option1: [
    { text: '全部商品', value: 0 },
    { text: '新款商品', value: 1 },
    { text: '活动商品', value: 2 },
  ],
  value1: 0,
})

自定义颜色

html

<pa-menu style="--pa-menu-active-color: red">
  <pa-menu-item v-model="state.value1" :options="state.option1"></pa-menu-item>
  <pa-menu-item v-model="state.value2" :options="state.option2"></pa-menu-item>
</pa-menu>
ts

import { reactive } from 'vue'

const state = reactive({
  option1: [
    { text: '全部商品', value: 0 },
    { text: '新款商品', value: 1 },
    { text: '活动商品', value: 2 },
  ],
  option2: [
    { text: '默认排序', value: 'a' },
    { text: '好评排序', value: 'b' },
    { text: '销量排序', value: 'c' },
  ],
  value1: 0,
  value2: 'a',
})

向上展开

html

<pa-menu direction="up">
  <pa-menu-item v-model="state.value1" :options="state.option1"></pa-menu-item>
  <pa-menu-item v-model="state.value2" :options="state.option2"></pa-menu-item>
</pa-menu>
ts

import { reactive } from 'vue'

const state = reactive({
  option1: [
    { text: '全部商品', value: 0 },
    { text: '新款商品', value: 1 },
    { text: '活动商品', value: 2 },
  ],
  option2: [
    { text: '默认排序', value: 'a' },
    { text: '好评排序', value: 'b' },
    { text: '销量排序', value: 'c' },
  ],
  value1: 0,
  value2: 'a',
})
参数说明类型默认值
direction菜单展开方向'up'|'down''down'
zIndex菜单栏 z-index 层级number10
duration动画时长,单位ms(string | number)[]200
overlay是否显示遮罩booleantrue
closeOnClickOverlay点击遮罩是否关闭弹窗booleantrue
参数说明类型默认值
title菜单项标题string''
modelValue当前选中项对应的 valueMenuItemOptionValue-
options选项数组MenuItemOption[]() => []
disabled是否禁用菜单boolean-
titleClass标题额外类名string''
事件名参数
事件名参数
update:modelValue(value: MenuItemOptionValue)
change(value: MenuItemOptionValue)
名称说明
default-
名称说明

样式变量

名称默认值
--pa-menu-height48px
--pa-menu-background#fff
--pa-menu-shadow0 2px 12px rgb(100 101 102 / 12%)
--pa-menu-title-padding0 8px
--pa-menu-title-colorvar(--pa-color-black)
--pa-menu-title-font-size15px
--pa-menu-title-line-height22px
--pa-menu-active-colorvar(--pa-color-primary)