我正在使用ColdFusion 9.1.2.
我有一个名为orders.cfm的CFC.这是"父母"CFC.
我有另一个CFC调用orderswrapup.cfc.这是orders.cfc的扩展.在orderswrapup.cfc中,我在顶部有这一行:
<cfcomponent extends="orders">
Run Code Online (Sandbox Code Playgroud)
现在,这不起作用:
objOrders = createObject("component", "orders");
MyResult = objOrders .someMethodActuallyInOrdersWrapUpCFC();
Run Code Online (Sandbox Code Playgroud)
但这确实有效:
objOrders = createObject("component", "orderswrapup");
MyResult = objOrders .someMethodActuallyInOrdersWrapUpCFC();
Run Code Online (Sandbox Code Playgroud)
要访问orderswrapup.cfc中的方法,我可以像调用"in"orders.cfc一样调用该方法,还是需要直接调用它?看来我应该能够打电话给父母,而不是孩子.
orderwrapup可以在创建新的orderswrapup对象时访问所有订单的功能,因为orderswrapup是订单的子项.
在定义orderswrapup.cfc时,您定义了orderswrapup.cfc继承所有orders.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