card 展示 json 不知道怎么取值
实现场景:
我期望使用 crud 展示 card 列表,每个 card 中使用 json 组件展示
存在的问题:
返回的数据在 items 数组中,不知道怎么将每个 item 全部赋值给 json 组件
当前方案:
{
type: 'crud',
filter: {
title: '条件搜索',
submitText: false,
wrapWithPanel: false,
controls: [
{
type: 'select',
name: 'selector.component',
label: '组件',
source: '/api/amis/options/components',
required: true
},
{
type: 'text',
name: 'selector.search',
addOn: {
label: '搜索',
type: 'submit'
},
trimContents: true,
required: true
}
]
},
api: '/api/amis/resources?component=${selector.component}&search=${selector.search}',
mode: 'cards',
card: {
body: {
type: 'json',
value: '${.}'
}
}
}
type: 'json'同级加name: 'xxx',xxx为获取变量key值
文档里也有,https://baidu.gitee.io/amis/docs/components/cards#%E5%9F%BA%E6%9C%AC%E7%94%A8%E6%B3%95

可以在不加 key 包一层的情况下直接引用整个 item 吗?
试试name:'$$'
{
type: 'crud',
syncLocation: false,
headerToolbar: [],
api: '/api/amis/resources?component=${selector.component}&search=${selector.search}',
mode: 'cards',
columnsCount: 2,
card: {
body: {
type: 'json',
value: '$$'
}
}
}
我修改的是 value,尝试过 $$ 和 ${$$} 都不能正常展示
我让你设置name,你设置的是啥
非常感谢,有用! 之前是没太理解为什么要设置 name...
之前是没太理解为什么要设置 name...
value是设置固定值,name一般是设置key来映射变量值的,功能不太一样
不过似乎多带了 "__super" 的属性,不知道有没有办法去掉

后来换 json-view 的实现了,如果还有问题再报吧