Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bee-autocomplete with all npm packages installed. Try it out:

require("react/package.json"); // react is a peer dependency. require("react-dom/package.json"); // react-dom is a peer dependency. require("prop-types/package.json"); // prop-types is a peer dependency. var beeAutocomplete = require("bee-autocomplete")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bee-autocomplete v2.0.4

AutoComplete ui component for react

bee-auto-complete

npm version Build Status Coverage Status devDependency Status NPM downloads Average time to resolve an issue Percentage of issues still open

react bee-auto-complete component for tinper-bee

根据用户的输入,进行自动匹配显示列表,用户可以进行按需选择自己需要的内容在输入框展示

使用方法

class Demo1 extends Component {
    constructor(props) {
        super(props);
        this.state = {
            value: "",
            options: ['10000(博宇)', '10001(波波)', '10002(李刚)'],
            placeholder: "查找关键字,请输入1",
            disabled: false
        }
        this.onFormChange = this.onFormChange.bind(this);
    }
    onFormChange(value) {
        this.setState({
            value: value
        })

    }
    render() {
        let { value, options, placeholder,disabled} = this.state;
        return (
            <div className="demo" style={{ "marginBottom": "90px" }}>
                <AutoComplete
                    value={value}
                    disabled={disabled}
                    options={options}
                    placeholder={placeholder}
                    onValueChange={value => this.onFormChange(value)}
                />

            </div>
        )
    }
}

API

参数说明类型默认值
value传入的输入框的值any-
options自动匹配列表array[]
placeholder输入框的默认提示string-
show控制自动匹配列表的展开和隐藏booleanfalse
disabled是否禁用输入框booleanfalse
onChange输入框值更改时触发的回调函数function-
onValueChange输入框值更改时触发的回调函数function-
onKeyDown监听input的键盘事件,调用此函数handleKeyDown()-
onBlurinput 的失去焦点时,调用此函数function-
onSelectOption被选中时调用,参数为选中项的 value 值function-

开发调试

$ npm install -g bee-tools
$ git clone https://github.com/tinper-bee/bee-auto-complete
$ cd bee-auto-complete
$ npm install
$ npm run dev
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free