我正在尝试添加一个接口到一个cfml文件中包含一些函数的cfml,但是它抛出了一个错误消息“Component...Does not implement the function .. of the interface”它抱怨的函数是在包含的cfml文件中实现的,我已经在railo 4和lucee 5中测试了这一点,并在两者中都得到了相同的错误,但它在coldfusion 11中工作。有人知道在lucee或railo中有解决方法或修复吗?
下面是重现错误的示例代码。
int.cfc
interface {
public numeric function func() output="false";
}comp.cfc
component implements="int" {
include "inc.cfm";
}inc.cfm
<cfscript>
public numeric function func() output="false"{
return 2;
}
</cfscript>index.cfm
<cfscript>
cfc = createObject("component", "comp");
writedump(cfc.func());
</cfscript>发布于 2017-06-28 22:12:25
我发现的一种可能的解决方法是用一个空的cfml替换掉原来的cfml文件,这个空的cfc实现了接口,但也扩展了原来重命名的cfml,通过替换原来的cfml,你可以在添加接口的同时保持相同的类型。因此,带有问题的示例的更新部分将如下所示
comp-to-extend.cfc
component implements="int" {
include "inc.cfm";
}comp.cfc
component extends="comp-to-extend" implements="int" {}https://stackoverflow.com/questions/44762174
复制相似问题