例如,我希望能够以编程方式命中一行代码,如下所示,在不使用Evaluate()的情况下动态分配函数名称.下面的代码当然不起作用,但代表了我想做的事情.
application.obj[funcName](argumentCollection=params)
Run Code Online (Sandbox Code Playgroud)
我可以找到动态调用函数的唯一方法是使用cfinvoke,但据我所知,它实时实例化相关的cfc /函数,不能使用以前实例化的cfc.
谢谢
根据文档,你可以做这样的事情:
<!--- Create the component instance. --->
<cfobject component="tellTime2" name="tellTimeObj">
<!--- Invoke the methods. --->
<cfinvoke component="#tellTimeObj#" method="getLocalTime" returnvariable="localTime">
<cfinvoke component="#tellTimeObj#" method="getUTCTime" returnvariable="UTCTime">
Run Code Online (Sandbox Code Playgroud)
您应该能够使用method ="#myMethod#"简单地调用它来动态调用特定函数.
| 归档时间: |
|
| 查看次数: |
3938 次 |
| 最近记录: |