当前位置:网站首页>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标签即可。
现在不管点击图标还是其他位置都可以展示下拉框了。
(完)
边栏推荐
- Priority_queue element as a pointer, the overloaded operators
- DDTL: Domain Transfer Learning at a Distance
- Download install and create/run project for HBuilderX
- 5. Scrapy middleware & distributed crawler
- Flask框架初学-05-命令管理Manager及数据库的使用
- 【Untitled】
- JS 从零教你手写节流throttle
- 织梦响应式酒店民宿住宿类网站织梦模板(自适应手机端)
- 通用的测试用例编写大全(登录测试/web测试等)
- 2022G1工业锅炉司炉考试练习题及模拟考试
猜你喜欢
随机推荐
esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
Slipper - virtual point, shortest path
可变字符串
[store mall project 01] environment preparation and testing
云开发旅游打卡广场微信小程序源码(含视频教程)
html select tag assignment database query result
web端动效 lottie-web 使用
工程制图名词解释-重点知识
C语言力扣第54题之螺旋矩阵。模拟旋转
Example 039: Inserting elements into an ordered list
Security First: Tools You Need to Know to Implement DevSecOps Best Practices
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
Oracle迁移到瀚高之后,空值问题处理
Hey, I had another fight with HR in the small group!
Deng Qinglin, Alibaba Cloud Technical Expert: Best Practices for Disaster Recovery across Availability Zones and Multiple Lives in Different Locations on the Cloud
splice随机添加和删除的写法
静态/动态代理模式
Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
GNSS[0]- Topic