Dash报错The children property of a component is a list of lists, instead of just a list.
是因为如果想给children属性赋值多个组件,必须是list中存放每个组件,不能list中存放list,ex:
[dcc.Graph(), dcc.Store(), dcc.Graph(), dcc.Store()]可以正常运行,
[ [dcc.Graph(), dcc.Store(), [dcc.Graph(), dcc.Store()] ]则不能正常运行。
可能引起报错的原因
某个方法返回多个组件,再用列表推导式调用这个方法,再return给children属性
解决办法
在列表推导式中解包:
a = [1, 2]
def test(t):
return t, "test"
ic([test(t) for t in a])
ic([res for t in a for res in test(t)])