Closed 0undefined0 closed 1 year ago
这个场景理解起来可能不太容易,首先这是一个service嵌套场景,子service的请求会先于父service执行,因此这里涉及到父service请求回来的数据更新数据域后,能够让子service感知到,在amis中是通过trackExpression这个属性来控制的。详细可以看这个说明 https://aisuda.bce.baidu.com/amis/zh-CN/docs/types/api#%E8%B7%9F%E8%B8%AA%E6%95%B0%E6%8D%AE%E8%87%AA%E5%8A%A8%E5%88%B7%E6%96%B0
你可以修改代码如下,及告诉子service跟踪date变量的变化("trackExpression": "${date}"):
{
"type": "page",
"data": {
"showtype": 0
},
"body": [
{
"type": "service",
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/page/initData",
"body": [
{
"type": "panel",
"title": "$title",
"body": [
{
"type": "tpl",
"tpl": "现在是:${date}",
"inline": false,
"id": "u:202f63e9ef7d"
}
],
"id": "u:99310706e1e9"
},
{
"type": "service",
"api": {
"method": "get",
"url": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/crud/table?perPage=5",
"messages": {
},
"trackExpression": "${date}"
"sendOn": "data.date=='2017-10-13'"
},
"body": [
{
"type": "table",
"title": "表格1",
"source": "$rows",
"columns": [
{
"name": "engine",
"label": "Engine",
"id": "u:d7f63d9a23aa"
},
{
"name": "version",
"label": "Version",
"id": "u:f54b504cefe8"
}
],
"id": "u:21da8a279125"
},
{
"type": "table",
"source": "$rows",
"columns": [
{
"name": "engine",
"label": "Engine",
"id": "u:5b45966b5cb4"
},
{
"name": "version",
"label": "Version",
"id": "u:9b18268a4226"
}
],
"id": "u:6c4bff49027c"
}
],
"id": "u:169e1ba5fc4f",
"messages": {
}
}
],
"id": "u:191196585a0a"
}
],
"id": "u:963ed0f7fa6e"
}