amis 俩个下拉框实现联动效果

pbpqsu0x  于 6个月前  发布在  其他
关注(0)|答案(4)|浏览(73)
实现场景:

使用编辑器操作面板在不修改源码的场景下,实现俩个下拉框接口联动效果

存在的问题:

在select1值变化回调中添加对select2的数据重新请求数据事件,在select2接口http配置中添加发送数据参数为select1,切换select值,select2重新请求了数据,但参数值拿到的是select1的旧值,并非当前值

当前方案:

klr1opcd

klr1opcd1#

表单项配置 strickMode: false

另外可以这个场景其实可以直接用这个机制 https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/linkage#%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8

0dxa2lsx

0dxa2lsx2#

表单项配置 strickMode: false

另外可以这个场景其实可以直接用这个机制 https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/linkage#%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8

{
"type": "form",
"body": [
{
"type": "select",
"label": "选项1",
"name": "select1",
"options": [
{
"label": "选项A",
"value": "A"
},
{
"label": "选项B",
"value": "B"
}
],
"id": "u:7fd35fab406e",
"multiple": false,
"onEvent": {
"change": {
"weight": 0,
"actions": [
{
"componentId": "u:3f3bf5be7036",
"ignoreError": false,
"actionType": "reload"
}
]
}
},
"strictMode": false
},
{
"type": "select",
"label": "选项2",
"name": "select2",
"id": "u:3f3bf5be7036",
"multiple": false,
"source": {
"url": "http://dnn1a1cvipdt",
"method": "post",
"data": {
"name": "${select1}"
}
},
"labelField": "name",
"valueField": "id",
"strictMode": false
}
],
"id": "u:68ad3b4c6589",
"actions": [
{
"type": "submit",
"label": "提交",
"primary": true,
"id": "u:dc795c3d4eee"
}
],
"feat": "Insert"
}

加了strictMode 没用

uubf1zoe

uubf1zoe3#

表单项配置 strickMode: false
另外可以这个场景其实可以直接用这个机制 https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/linkage#%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8

{ "type": "form", "body": [ { "type": "select", "label": "选项1", "name": "select1", "options": [ { "label": "选项A", "value": "A" }, { "label": "选项B", "value": "B" } ], "id": "u:7fd35fab406e", "multiple": false, "onEvent": { "change": { "weight": 0, "actions": [ { "componentId": "u:3f3bf5be7036", "ignoreError": false, "actionType": "reload" } ] } }, "strictMode": false }, { "type": "select", "label": "选项2", "name": "select2", "id": "u:3f3bf5be7036", "multiple": false, "source": { "url": "http://dnn1a1cvipdt", "method": "post", "data": { "name": "${select1}" } }, "labelField": "name", "valueField": "id", "strictMode": false } ], "id": "u:68ad3b4c6589", "actions": [ { "type": "submit", "label": "提交", "primary": true, "id": "u:dc795c3d4eee" } ], "feat": "Insert" }

加了strictMode 没用

现在的应用场景是只使用编辑器的可视化面板进行配置 能不能用可视化面板在不更改源码的情况下实现这一需求

r6hnlfcb

r6hnlfcb4#

在chang 里加了 debounce防抖就可以拿到最新的值了

相关问题