1、新建webcore application项目。
2、新建webcore web data module模块。
3、在第2步中添加代码。
unit Unit2;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Modules;
type
TdmMain = class(TWebDataModule)
private
function get_TheAnswer: string; //属性
public
property TheAnswer: string read get_TheAnswer; //函数
end;
var
dmMain: TdmMain;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
function TdmMain.get_TheAnswer: string;
const
cTheAnswer = '42';
begin
Result := cTheAnswer;
end;
end.
procedure TForm1.WebButton1Click(Sender: TObject);
begin
ShowMessage(dmMain.TheAnswer);
end;
结果.