【发布时间】:2015-04-04 19:24:28
【问题描述】:
我和 Aurelia 一起玩,看起来很不错,我在一些项目中使用 Durandal,这绝对适合我的需求。
使用来自 EC6 的新类定义很棒。但是现在我正在准备一些东西,我需要在其中使用带有 requireJs 的经典 AMD 模块,就像这样:
define("testModule",
[],
function() {
"use strict";
console.log('testModule loaded');
var testModule = function() {
var that = this;
this.variable = 10;
that.getVariable = function(){
alert('function executed ' + that.variable);
};
}
return testModule;
});
按照 Aurelia 的文档,我发现可以将 testModule 之类的东西用作 ViewModel,事实上,在 Durandal 应用程序中使用了 viewModel。
但经过一些尝试后,我无法使其正常工作。
有人遵循什么想法或方法来做到这一点? 最重要的是,有可能吗?我认为这只是为了确认它们是兼容的。
谢谢。
【问题讨论】:
标签: javascript requirejs durandal amd aurelia