Skip to content

Category 商品分类

介绍

用于展示商品分类的组件。

基础用法

data 数据格式可参考 categoryData.js

html
<template>
  <nut-category :category="category" @change="onCategoryChange">
    <nut-category-pane :category-child="categoryChild" @onChange="onCategoryPaneChange" />
  </nut-category>
</template>
ts
const category = ref([
  // ...
]);
const categoryChild = ref([
  // ...
]);

function onCategoryChange(index: number) {
  categoryChild.value = [].concat(category.value[index].children);
}

function onCategoryPaneChange(value: any) {
  console.log("当前分类数据", value);
}

自定义分类

html
<template>
  <nut-category>
    <nut-category-pane type="custom" :customCategory="customCategoryData"></nut-category-pane>
  </nut-category>
</template>

API

Props

参数说明类型可选值默认值
type分类模式stringclassify / text / customclassify
category左侧导航栏数据列表Array-[]

Events

事件名说明类型
change点击左侧导航栏时触发(index: number) => void

CategoryPane Props

参数说明类型可选值默认值
type分类模式stringclassify / text / customclassify
category-child右侧展示当前分类数据Array-[]
custom-category自定义分类数据Array-[]

CategoryPane Events

事件名说明类型
on-change点击右侧分类数据触发(item: any) => void

CategoryPane Slots

名称说明
default自定义内容

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件

名称默认值
--nut-category-bg-colorrgba(255, 255, 255, 1)
--nut-category-list-left-bg-colorrgba(246, 247, 249, 1)
--nut-category-list-item-colorvar(--nut-title-color)
--nut-category-list-item-checked-colorrgba(255, 255, 255, 1)
--nut-category-list-item-checked-img-bg-colorvar(--nut-primary-color)
--nut-category-pane-gray-color#666
--nut-category-pane-border-colorrgb(153, 153, 153)
--nut-category-pane-title-colorrgba(51, 51, 51, 1)

MIT Licensed