react-bootstrap-async-autocomplete

2019-07-13 admin

react-bootstrap-async-autocomplete是什么

什么是react-bootstrap-async-autocomplete,Async autocomplete component using react-bootstrap

react-bootstrap-async-autocomplete使用教程帮助文档

react-bootstrap-async-autocomplete

An autocomplete input for react-bootstrap using an async datasource

Live demo: http://cdn.rawgit.com/nnarhinen/react-bootstrap-async-autocomplete/master/example/index.html

Source of demo: example.js

Installation

npm install react-bootstrap-async-autocomplete

Usage

var AutocompleteInput = require('react-bootstrap-async-autocomplete');
    React = require('react');

var searchRequested = function(key, cb) {
  setTimeout(function() { //Emulate async
    var results = [];
    for (var i = 0; i < 10; i++) {
      results.push(key + i);
    }
    cb(results);
  }, 1000);
};

var itemSelected = function(itm) {
  alert(itm + ' selected');
};

//AutocompleteInput accepts all same props that react-bootstrap/Input
React.renderComponent(<AutoCompleteInput label="Some label" placeholder="Start typing.." onSearch={searchRequested} onItemSelect={itemSelected} />, document.body);

Author

Niklas Närhinen niklas@narhinen.net

License

The MIT license

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69617.html

文章标题:react-bootstrap-async-autocomplete

回到顶部