最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

React?程序設計簡單的輕量級自動完成搜索框應用

 更新時間:2022年10月25日 15:22:10   作者:Jovie  
這篇文章主要為大家介紹了React?程序設計簡單的輕量級自動完成搜索框應用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

實現(xiàn)效果

一個為React應用程序設計的簡單的輕量級自動完成搜索框。

如何使用它

1.安裝并導入該組件

# Yarn
$ yarn add react-search-box
# NPM
$ npm i react-search-box
import React, { Component } from "react";
import ReactSearchBox from "react-search-box";

2.將ReactSearchBox 組件添加到應用程序中

<ReactSearchBox
  placeholder="Type Something..."
  value="ReactScript"
  data={this.data}
  callback={(record) => console.log(record)}
/>

3.定義你的自動建議列表的數(shù)據(jù)

export default class App extends Component {
  data = [
    {
      key: "react",
      value: "React Native",
    },
    {
      key: "vue",
      value: "Vue Component",
    },
    // ...
  ];
  render() {
    return (
      <ReactSearchBox
        placeholder="Type Something..."
        value="ReactScript"
        data={this.data}
        callback={(record) => console.log(record)}
      />
    );
  }
}

4.所有可用的組件道具

/*
 * The placeholder text for the input box.
 */
placeholder: string;
/*
 * The name attribute for the input box.
 */
name?: string;
/*
 * An array of objects which acts as the source of data for the dropdown. This prop is required.
 */
data: { key: string; value: string }[];
/*
 * Configs to override default Fuse configs.
 */
fuseConfigs?: {};
/*
 * Focus on the input box once the component is mounted.
 */
autoFocus?: boolean;
/*
 * A function which acts as a callback when any record is selected. It is triggered once a dropdown item is clicked.
 */
onSelect: (record: Record) => void;
/*
 * A function which acts as a callback when the input is focussed.
 */
onFocus?: () => void;
/*
 * A function which acts as a callback when the input value is changed.
 */
onChange: (value: string) => void;
/*
 * Color of the text in the input box.
 */
inputFontColor?: string;
/*
 * Color of the border of the input box.
 */
inputBorderColor?: string;
/*
 * Size of the font of the input box.
 */
inputFontSize?: string;
/*
 * Height of the input box.
 */
inputHeight?: string;
/*
 * Background color of the input box.
 */
inputBackgroundColor?: string;
/*
 * Background color on hover of the dropdown list items.
 */
dropdownHoverColor?: string;
/*
 * Border color of the dropdown.
 */
dropdownBorderColor?: string;
/*
 * Clear the input value when any record is selected.
 */
clearOnSelect?: boolean;
/*
 * Icon to be rendered on the left of the input box.
 */
leftIcon?: ReactNode;
/*
 * The size of the icon (based on the leftIcon prop).
 */
iconBoxSize?: number | string;
/*
 * The type of the input.
 */
type?: string;

預覽

The postAutocomplete Search Box For Reactappeared first onReactScript.

以上就是React 程序設計簡單的輕量級自動完成搜索框應用的詳細內(nèi)容,更多關于React 輕量級自動搜索框的資料請關注腳本之家其它相關文章!

相關文章

  • react批量引入svg圖標的方法

    react批量引入svg圖標的方法

    這篇文章主要介紹了react批量引入svg圖標的方法,在批量引入之前,我們需要安裝一個包并配置到typescript.json文件中,需要的朋友可以參考下
    2024-03-03
  • react動態(tài)路由的實現(xiàn)示例

    react動態(tài)路由的實現(xiàn)示例

    React中動態(tài)路由通過ReactRouter庫實現(xiàn),根據(jù)應用狀態(tài)或用戶交互動態(tài)顯示或隱藏組件,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-11-11
  • React Antd中如何設置表單只輸入數(shù)字

    React Antd中如何設置表單只輸入數(shù)字

    這篇文章主要介紹了React Antd中如何設置表單只輸入數(shù)字問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • React類組件中super()和super(props)的區(qū)別詳解

    React類組件中super()和super(props)的區(qū)別詳解

    這篇文章給大家詳細介紹了React類組件中super()和super(props)有什么區(qū)別,文中通過代碼示例給大家介紹的非常詳細,對大家的學習或工作有一定的幫助,需要的朋友可以參考下
    2024-01-01
  • react hooks實現(xiàn)原理解析

    react hooks實現(xiàn)原理解析

    這篇文章主要介紹了react hooks實現(xiàn)原理,文中給大家介紹了useState dispatch 函數(shù)如何與其使用的 Function Component 進行綁定,節(jié)后實例代碼給大家介紹的非常詳細,需要的朋友可以參考下
    2022-10-10
  • React競態(tài)條件Race Condition實例詳解

    React競態(tài)條件Race Condition實例詳解

    這篇文章主要為大家介紹了React競態(tài)條件Race Condition實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • ReactJs快速入門教程(精華版)

    ReactJs快速入門教程(精華版)

    React 起源于 Facebook 的內(nèi)部項目,因為該公司對市場上所有 JavaScript MVC 框架,都不滿意,就決定自己寫一套,用來架設 Instagram 的網(wǎng)站.這篇文章主要介紹了ReactJs快速入門教程(精華版)的相關資料,需要的朋友可以參考下
    2016-11-11
  • React?SSR架構Stream?Rendering與Suspense?for?Data?Fetching

    React?SSR架構Stream?Rendering與Suspense?for?Data?Fetching

    這篇文章主要為大家介紹了React?SSR架構Stream?Rendering與Suspense?for?Data?Fetching解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-03-03
  • TS裝飾器bindThis優(yōu)雅實現(xiàn)React類組件中this綁定

    TS裝飾器bindThis優(yōu)雅實現(xiàn)React類組件中this綁定

    這篇文章主要為大家介紹了TS裝飾器bindThis優(yōu)雅實現(xiàn)React類組件中this綁定,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • React從插槽、路由、redux的詳細過程

    React從插槽、路由、redux的詳細過程

    React需要自己開發(fā)支持插槽功能,原理:父組件組件中寫入的HTML,可以傳入子組件的props中,這篇文章主要介紹了React從插槽、路由、redux的詳細過程,需要的朋友可以參考下
    2022-10-10

最新評論

玉门市| 正阳县| 行唐县| 雅江县| 南岸区| 通化市| 河北省| 余江县| 凤凰县| 布尔津县| 武清区| 怀宁县| 罗江县| 远安县| 太仓市| 胶南市| 穆棱市| 舞钢市| 卓尼县| 宜兰市| 阿尔山市| 贺州市| 三门县| 偃师市| 正阳县| 辽中县| 喀喇沁旗| 营口市| 安岳县| 汉阴县| 厦门市| 乌鲁木齐市| 南陵县| 天祝| 顺义区| 青龙| 平原县| 琼中| 云安县| 龙游县| 九龙城区|