亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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應用中避免白屏現(xiàn)象的方法小結

    React應用中避免白屏現(xiàn)象的方法小結

    在開發(fā)React應用程序時,我們都曾遇到過這樣的場景:一個未被捕獲的異常突然中斷了組件的渲染流程,導致用戶界面呈現(xiàn)出一片空白,也就是俗稱的“白屏”現(xiàn)象,本文將探討如何在React應用中有效捕獲并處理這些錯誤,避免白屏現(xiàn)象的發(fā)生,需要的朋友可以參考下
    2024-06-06
  • React創(chuàng)建組件的三種方式及其區(qū)別是什么

    React創(chuàng)建組件的三種方式及其區(qū)別是什么

    在React中,創(chuàng)建組件的三種主要方式是函數(shù)式組件、類組件和使用React Hooks的函數(shù)式組件,本文就詳細的介紹一下如何使用,感興趣的可以了解一下
    2023-08-08
  • React中使用Vditor自定義圖片詳解

    React中使用Vditor自定義圖片詳解

    這篇文章主要介紹了React中使用Vditor自定義圖片詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-12-12
  • 詳解React中傳入組件的props改變時更新組件的幾種實現(xiàn)方法

    詳解React中傳入組件的props改變時更新組件的幾種實現(xiàn)方法

    這篇文章主要介紹了詳解React中傳入組件的props改變時更新組件的幾種實現(xiàn)方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-09-09
  • React immer與Redux Toolkit使用教程詳解

    React immer與Redux Toolkit使用教程詳解

    這篇文章主要介紹了React中immer與Redux Toolkit的使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習吧
    2022-10-10
  • 詳解antd+react項目遷移vite的解決方案

    詳解antd+react項目遷移vite的解決方案

    這篇文章主要介紹了詳解antd+react項目遷移vite的解決方案,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-04-04
  • ahooks useVirtualList 封裝虛擬滾動列表

    ahooks useVirtualList 封裝虛擬滾動列表

    這篇文章主要為大家介紹了ahooks useVirtualList 封裝虛擬滾動列表詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-09-09
  • React中Ref 的使用方法詳解

    React中Ref 的使用方法詳解

    這篇文章主要介紹了React中Ref 的使用方法,結合實例形式總結分析了react中ref基本功能、用法及操作注意事項,需要的朋友可以參考下
    2020-04-04
  • react項目中如何引入國際化

    react項目中如何引入國際化

    在React項目中引入國際化可以使用第三方庫來實現(xiàn),本文主要介紹了react項目中如何引入國際化,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-07-07
  • 關于antd tree和父子組件之間的傳值問題(react 總結)

    關于antd tree和父子組件之間的傳值問題(react 總結)

    這篇文章主要介紹了關于antd tree 和父子組件之間的傳值問題,是小編給大家總結的一些react知識點,本文通過一個項目需求實例代碼詳解給大家介紹的非常詳細,需要的朋友可以參考下
    2021-06-06

最新評論