【问题标题】:In ColdFusion is it possible to pass an array to a custom tag?在 ColdFusion 中是否可以将数组传递给自定义标签?
【发布时间】:2020-02-04 12:21:57
【问题描述】:

我想将数组传递给自定义标签。这可能吗? 我有一个数组阵列产品。在我的 cfm 中,我调用了自定义标签:

<cf_cu_show_productcategories thename="#thename#" thenameprod="#thenameprod#" arrayProd="#arrayProd#">

自定义标签:

<cfparam name="attributes.thename" default="">
<cfparam name="attributes.thenameprod" default="">
<cfparam name="attributes.arrayProd" type="array" default="">

在自定义标记中使用此 arrayProd 会导致“变量 ARRAYPROD 未定义”。

【问题讨论】:

  • 如何访问导致错误消息的ARRAYPROD
  • 确实,我发现我只能通过 arryProd 而不是 attributes.arrayProd 访问它。谢谢。
  • 访问自定义标签属性时使用属性范围。所以应该是Attributes.arrayProd。
  • @Bernard Döbler;您能否写下您的评论作为对这篇文章的回答,以便我可以将其设置为已解决?确实是您的评论使我忘记了使用attributes.arrayProd。现在我无法将此帖子标记为已解决。

标签: arrays coldfusion cfml custom-tags


【解决方案1】:

默认属性应该是default="#[]#"

【讨论】:

  • 或者老式的default="#ArrayNew(1)#"
  • 是的。尽管即使进行了更改,它仍然会为我抛出未定义的错误。猜猜我忘记了 CF 在评估非作用域变量时不包括 attributes,例如在 cmets stackoverflow.com/questions/58265590/… 中推断的 @Redtopia 和 Veni@
猜你喜欢
  • 1970-01-01
  • 2013-05-07
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 2018-04-04
  • 1970-01-01
  • 2013-07-06
  • 2018-09-09
相关资源
最近更新 更多