baidu / baidu/amis

combo组合 自定义删除按钮 index问题

Open
#7,633 0 comments 0 reactions 0 assignees View on GitHub
need confirm
Dominant language
TypeScript
Stars
18.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

#### 描述问题:

在使用combo组合的自定义删除按钮时,使用变量$index,得到的值一直是 0

#### 截图或视频:

![image](https://github.com/baidu/amis/assets/55941738/2d9a25a6-066d-492c-9452-994ae0835c9d)

#### 如何复现(请务必完整填写下面内容):

官方的案例是
...
"deleteBtn": {
"type": "button",
"label": "delete",
"level": "danger",
"tooltip": "提示文本",
"tooltipPlacement": "top",
"onClick": "alert(index)"
},
...
这样获取到的index是正常的,但是我需要调用api接口,如:
...
deleteBtn: {
type: 'button',
label: '删除',
actionType: 'ajax',
api: "http://xxxx.com/?id=${index}"
},
...
这样获取到的index一直是 0

1. 你是如何使用 amis 的?
sdk

2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在
v2.8.0

3. 粘贴有问题的完整 `amis schema` 代码:
```
{
type: 'combo',
name: 'combo',
multiple: true,
draggable: true,
unique: true,
deleteBtn: {
type: 'button',
label: '删除',
actionType: 'ajax',
api: "http://xxxx.com/?id=${index}"
},
items: [
{
type: 'group',
body: [
{
type: "input-text",
name: "name",
columnRatio: 2,
},
{
type: "input-text",
name: "url",
columnRatio: 4,
},
]
}
]
},
```

4. 操作步骤
无需操作

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the provided combo schema, comparing the custom delete button's alert(index) behavior with index interpolation in the ajax api URL. Trace how the combo item context is passed to each action, and consider the issue done when the ajax URL receives the correct item index rather than always 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.