当前位置:网站首页>ant-design的Select组件采用自定义后缀图标(suffixIcon属性)时,点击该自定义图标没有反应,不会展示下拉菜单的问题
ant-design的Select组件采用自定义后缀图标(suffixIcon属性)时,点击该自定义图标没有反应,不会展示下拉菜单的问题
2022-08-04 02:03:00 【霜雪遥】
一. 问题原因
自定义图标采用了ant-design的Icon图标组件
我是在ant-design-react的项目中出现的这个问题,估计ant-design-vue中也会这样。
import {
CaretDownOutlined } from '@ant-design/icons'
import {
Select } from 'antd'
<Select
size='large'
showArrow
bordered={
false}
value={
selTransactionType}
options={
transactionOptions}
onChange={
handleTransactionTypeChange}
suffixIcon={
<CaretDownOutlined style={
{
fontSize: '15px', color: '#CBD0DB' }} />}
/>
点击Select其他部分都可以展示下拉框,唯独点击图标没有反应。
二. 解决办法
让UI同学将这个箭头切下来,通过标签的形式放上去
import {
CaretDownOutlined } from '@ant-design/icons'
import {
Select, Image } from 'antd'
<Select
size='large'
showArrow
bordered={
false}
value={
selTransactionType}
options={
transactionOptions}
onChange={
handleTransactionTypeChange}
suffixIcon={
<Image
src={
'https://XXXXXXXXXX/date-icon.png'}
alt='coverImage'
preview={
false}
style={
{
width: '16px', height: '16px' }}
/>
<img
src={
'https://XXXXXXXXXX/date-icon.png'}
alt='coverImage'
style={
{
width: '16px', height: '16px' }}
/>
}
/>
若是使用ant-design的Image组件,ant-design的Image组件自带预览图片功能,记得需要将preview置为false。
或者直接用img标签即可。
现在不管点击图标还是其他位置都可以展示下拉框了。
(完)
边栏推荐
- Example 041: Methods and variables of a class
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- 实例041:类的方法与变量
- 安全至上:落地DevSecOps最佳实践你不得不知道的工具
- LDO investigation
- 内网穿透-应用
- FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
- sudo 权限控制,简易
- Quickly build a website with static files
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
猜你喜欢
Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud
2022G1工业锅炉司炉考试练习题及模拟考试
5.scrapy中间件&分布式爬虫
工程制图复习题(带答案)
Parquet encoding
织梦响应式酒店民宿住宿类网站织梦模板(自适应手机端)
Quickly build a website with static files
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
Array_Sliding window | leecode brushing notes
esp32发布机器人电池电压到ros2(micro-ros+CoCube)
随机推荐
Installation and configuration of nodejs+npm
持续投入商品研发,叮咚买菜赢在了供应链投入上
Quickly build a website with static files
实例038:矩阵对角线之和
可变字符串
FeatureNotFound( bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested:
工程制图平面投影练习
C语言:学生管理系统(链表版)
Summary of GNSS Articles
第13章 网络安全漏洞防护技术原理与应用
ssh服务详解
第08章 索引的创建与设计原则【2.索引及调优篇】【MySQL高级】
lombok注解@RequiredArgsConstructor的使用
22/8/3(板子)树状dp板子+中国剩余定理+求组合数3,4+容斥原理
sudo 权限控制,简易
Presto中broadcast join和partition join执行计划的处理过程
2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
天地图坐标系转高德坐标系 WGS84转GCJ02
2022年T电梯修理考题及答案
DDTL: Domain Transfer Learning at a Distance