我有状态的阵列和数量等的室外:如何获得密钥的值在树枝阵列循环
(州,计数)
states=[
'ACT' => 25,
'NSW' => 45,
'VIC' => 18,
'SA' => 12
]
我想获取树枝中每个状态的值(循环外)。
所以对于每一个状态(如动态参数)我需要得到 “计数” 值:
{{ attribute(states, state_name).count }}
或
{{ attribute(states, count)}}
,但不工作。
有什么想法?
编辑: 此代码正在工作,但无法从循环中获取值。 在这段代码中,我需要多次运行循环。
{% for state in states %}
{% if state.state_name == state_name %}
({{ state.count }})
{% endif %}
{% endfor %}
像'{{属性(州,STATE_NAME)}}'? – aghidini
'{{states [state_name]}}'? – jeroen
对不起,他们都没有工作。 – Ashkan