小编Ani*_*wal的帖子

在 react-select 中的 input 元素前添加一个图标

我正在尝试在 react select 的输入元素前面添加一个图标。我能够在占位符中获取图标,但占位符的问题是当我从下拉列表中选择一些数据时,占位符图标会被删除。我需要一些帮助来获取 Select 语句前面的图标。

这是我到目前为止所取得的成就的代码

import React, { Component } from 'react'
import Select, { components } from 'react-select'

export default class InfluencersForm extends Component {

    constructor(){
        super();
        this.handleInfluencerName = this.handleInfluencerName.bind(this);
    }
    handleInfluencerName(event){
        console.log(event)
    }
    render() {
        const influencers = [
            { value: 'abc', label: 'abc' },
            { value: 'def', label: 'def' }
        ]

        const DropdownIndicator = (props) => {
            return components.DropdownIndicator && (
                <components.DropdownIndicator {...props}>
                    <i className="fa fa-search" aria-hidden="true" style={{ position: 'initial' }}></i>
                </components.DropdownIndicator>
            );
        };
        return …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-select

7
推荐指数
1
解决办法
1万
查看次数

标签 统计

javascript ×1

react-select ×1

reactjs ×1