Coldfusion:设置对象的功能

Saa*_*d A 1 coldfusion cfwheels

我有一个模型对象;

building= model("tb_buildings");
building.myFunction() = function(){return false;};
Run Code Online (Sandbox Code Playgroud)

最初这个对象没有方法,我试图为它创建一个名为myFunction()的方法,并为其赋值false; 我尝试了匿名函数方法,但它给了我一个错误;

Cannot assign a value to a function
Run Code Online (Sandbox Code Playgroud)

这可能吗?

Jam*_*ler 8

要将变量设置为函数,您应该这样做

building.myFunction = function(){ return false; };
Run Code Online (Sandbox Code Playgroud)