如何通过组件传递参数 [英] How to pass parameters through components
本文介绍了如何通过组件传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个实例包含3个或更多组件。
我需要为每个儿子传递一个参数
有办法吗?
I have a component that instances 3 or more components. I need to pass one parameter for each of his sons Is there a way to do it?
例如这样的代码:
<cq:include path="x" resourceType="compo">
<parameter....>
</cq:include>
推荐答案
有一个很简单的解决方案:
There is pretty easy solution:
- 在主组件中,通过请求 scope
(< c:set var = param value = 10 scope = request />
)。 - 在组件中,您多次使用主变量
来使用变量
$ {param}
- In your main component define variable with request scope
(
<c:set var="param" value="10" scope="request" />
). - In component,
which you include several times in main one you van use variable
${param}
这篇关于如何通过组件传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文