index.md 1005 Bytes

title: 组件

排序规则

import React, { useState } from 'react';
import { QxSortCondition } from './index';

const options2 = [
  {
    label: '创建时间',
    value: 'created_at',
  },
  {
    label: '记录ID',
    value: 'id',
    icon: '图标',
  },
  {
    label: '标题',
    value: 'wdT8w5ZlCWPhjRzBq8E',
  },
  {
    label: '描述',
    value: 'y8OOH2fDNaFQ7ixioX0',
  },
  {
    label: '文本',
    value: '2rd3ePcrGcQolUbCLWL',
  },
  {
    label: '数值',
    value: '4pQVBruE0gtnjT8eGso',
  },
];

export default () => {
  const [values, setValues] = useState<
    {
      key: string;
      asc: boolean;
    }[]
  >([
    {
      key: 'created_at',
      asc: false,
    },
  ]);

  const props = {
    onChange: (
      _val: {
        key: string;
        asc: boolean;
      }[],
    ) => {
      setValues(_val);
    },
    value: values,
    optionList: options2,
  };

  return <QxSortCondition {...props} />;
};
// <API id="QxSortCondition"></API>