gpt4 book ai didi

coldfusion - 这两个组件有何不同?

转载 作者:行者123 更新时间:2023-12-04 01:53:37 26 4
gpt4 key购买 nike

其中一个比另一个更好吗?有什么不同?它们似乎可以互换

component
{
property name="some_thing" type="string" value="";
}

对比

component
{
this.some_thing = "";
}

最佳答案

cf属性

在 CF8 之后,“cfproperty”允许设置一个隐式的 setter/getter。

它还用于创建 Web 服务和 ORM 应用程序,并具有大量配置属性:

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-p-q/cfproperty.html

setter / getter

com/foo.cfc

component accessors='true' { 

// set properties & variables above any component methods

property name='bar' type='string';
this.setBar('foo');

function init(){
return this;
}

}

在模板“foo.cfm”中:

foo = new com.foo();
WriteDump(var=foo.getBar());
// foo

'这个'范围

“this”作用域可以在组件内部和外部访问。

com/foo.cfc

component { 

// set properties & variables above any component methods

this.bar = 'foo';

function init(){
return this;
}

}

在模板“foo.cfm”中:

foo = new com.foo();
WriteDump(var=foo.bar);
// foo

组件内的“变量”范围

无法从组件外部访问组件内的变量作用域。

关于coldfusion - 这两个组件有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55031687/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com