我使用的是ColdFusion 9.1.2。
我有一个叫orders.cfm的CFC。这就是“父”CFC。
我还有另一个CFC调用orderswrapup.cfc。这是orders.cfc的一个扩展。在orderswrapup.cfc中,我在顶部有这一行:
<cfcomponent extends="orders">现在,这是行不通的:
objOrders = createObject("component", "orders");
MyResult = objOrders .someMethodActuallyInOrdersWrapUpCFC();但这确实起作用了:
objOrders = createObject("component", "orderswrapup");
MyResult = objOrders .someMethodActuallyInOrdersWrapUpCFC();要访问orderswrapup.cfc中的方法,我可以像在orders.cfc中一样调用该方法,还是需要直接调用它?似乎我应该能够呼叫父母,而不是孩子。
发布于 2011-12-21 01:54:40
创建新的orderswrapup对象时,orderswrapup可以访问order的所有函数,因为orderswrapup是order的子级。
您定义了orderswrapup.cfc来继承orders.cfc的所有函数,当您将orderswrapup.cfc定义为<cfcomponent extends="orders">时,这允许您通过orderswrapup.cfc调用orders.cfc中的任何函数,就像它们是orders.cfc中的函数一样。但是orders.cfc与orderswrapup.cfc没有定义的关系,所以它不能调用orderswrapup.cfc内部的函数
一些好的编写-- http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_30.html
发布于 2012-01-18 23:45:44
扩展cfcs的成本很高。
如果你发现自己需要进行超过3个级别的扩展,你会开始注意到性能的影响。
https://stackoverflow.com/questions/8579568
复制相似问题