当前位置:网站首页>[pit avoidance refers to "difficult"] antd cascader implements new customized functions
[pit avoidance refers to "difficult"] antd cascader implements new customized functions
2022-06-25 13:16:00 【Coconut brine Engineer】
The renderings are as follows : You can customize how to add data in a certain layer 
Code implementation
Yes Cascader Medium options Do the processing
<Cascader
allowClear
expandTrigger="hover"
options={
customerOption}
/>
const customerOption = handlecustomerOption(showoptions);
const handlecustomerOption=(opt: any) =>{
if (opt && opt.length) {
opt.forEach((item: any) => {
if (item.children && item.children.length) {
item.fieldNames = item.value;
item.children.forEach((child: any) => {
let tempObj = {
};
tempObj = {
label: (
<span>
<span title={
child.value} className="layoutTitle">{
child.label}</span>
{
child.label ?'':
<Button
type="link"
icon={
<PlusOutlined />}
style={
{
marginTop: -5 }}>
newly added
</Button>}
</span>
),
value: child.value,
fieldNames: child.value,
};
Object.assign(child, tempObj);
});
}
});
}
option initialization JSON The format is as follows :
const showoptions = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: '',
label: '',
},
{
value: 'hangzhou',
label: 'Hangzhou',
children: [
{
value: 'xihu',
label: 'West Lake',
},
],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
},
],
},
];
{value: '',label: '',} It is equivalent to occupying the top first position in the drop-down data , adopt handlecustomerOption() take label replaced button, So as to realize the new functions .
边栏推荐
- 數據在內存中的存儲相關內容
- Optimization of lazyagg query rewriting in parsing data warehouse
- list. replace, str.append
- 字符串入门十八讲合集四
- 关于扫雷的简易实现
- Spoken English - weak reading
- Germany holds global food security Solidarity Conference
- Oracle trigger error report table or view does not exist
- Elemntui's select+tree implements the search function
- Sword finger offer 04 Find in 2D array
猜你喜欢

Introduction to mongodb chapter 01 introduction to mongodb

Uncover gaussdb (for redis): comprehensive comparison of CODIS

Django框架——缓存、信号、跨站请求伪造、 跨域问题、cookie-session-token

CUDA error: unspecified launch failure

Online service emergency research methodology

Capabilities required by architects

剑指 Offer II 025. 链表中的两数相加

坡道带来的困惑

Command line garbled

关于扫雷的简易实现
随机推荐
Drawing cubes with Visio
KVM script management - the road to dream
关于数据在内存中存储的相关例题
[machine learning] model and cost function
Event triggered when El select Clear clears content
深圳民太安智能二面_秋招第一份offer
KDD 2022 | graphmae: self supervised mask map self encoder
提高排名的 15 个基本 SEO 技巧
nacos无法修改配置文件Mysql8.0的解决方法
Serenvlt first met
[machine learning] what is machine learning?
Qt显示FFmpeg解码的图片
Stockage des données en mémoire
[flask tutorial] flask overview
Update PIP & Download jupyter Lab
Seven competencies required by architects
Fedora 35 deploys DNS master-slave and separation resolution -- the way to build a dream
Golang keyboard input statement scanln scanf code example
Heavyweight live | bizdevops: the way to break the technology situation under the tide of digital transformation
剑指 Offer II 028. 展平多级双向链表