您现在的位置是:网站首页> 编程资料编程资料
React 程序设计简单的轻量级自动完成搜索框应用_React_
2023-05-24
450人已围观
简介 React 程序设计简单的轻量级自动完成搜索框应用_React_
实现效果

一个为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 组件添加到应用程序中
console.log(record)} />
3.定义你的自动建议列表的数据
export default class App extends Component { data = [ { key: "react", value: "React Native", }, { key: "vue", value: "Vue Component", }, // ... ]; render() { return ( 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 程序设计简单的轻量级自动完成搜索框应用的详细内容,更多关于React 轻量级自动搜索框的资料请关注其它相关文章!
您可能感兴趣的文章:
相关内容
- Vue中监视属性和计算属性区别解析_vue.js_
- vue cli实现项目登陆页面流程详解_vue.js_
- React动画实现方案Framer Motion让页面自己动起来_React_
- Vue项目中使用百度地图api的详细步骤_vue.js_
- Nodejs Sequelize手册学习快速入门到应用_node.js_
- VUE设置和清除定时器的方式及遇到的问题_vue.js_
- Vue实用功能之实现拖拽元素、列表拖拽排序_vue.js_
- Vue项目部署到IIS后刷新报错404的问题及解决方法_vue.js_
- Vue 中 createElement 使用实例详解_vue.js_
- React中classnames库使用示例_React_
