ant-design/components/mentions/demo/basic.md
黑雨 066be35de3
feat: support options (#38876)
* feat: support options

* feat: update package

* feat: update package

* feat: update doc

* feat: update doc

* feat: update doc

* feat:  add test case
2022-11-23 21:00:24 +08:00

813 B

order title
0
zh-CN en-US
基本使用 Basic

zh-CN

基本使用。

en-US

Basic usage.

import React from 'react';
import { Mentions } from 'antd';
import type { MentionsOptionProps } from 'antd/es/mentions';

const onChange = (value: string) => {
  console.log('Change:', value);
};

const onSelect = (option: MentionsOptionProps) => {
  console.log('select', option);
};

const App: React.FC = () => (
  <Mentions
    style={{ width: '100%' }}
    onChange={onChange}
    onSelect={onSelect}
    defaultValue="@afc163"
    options={[
      {
        value: 'afc163',
        label: 'afc163',
      },
      {
        value: 'zombieJ',
        label: 'zombieJ',
      },
      {
        value: 'yesmeck',
        label: 'yesmeck',
      },
    ]}
  />
);

export default App;