Ami*_*eza 6 typescript durandal hottowel
这是我的第一篇文章,祝我好运:)
我想使用热毛巾(durandal)+打字稿,我遵循这些线程: - 我怎么用-a-class-for-my-shell-viewmodel-in-durandal - how-to-use-fancybox-与durandal-en-typescript组合 - 错误 - 这是在选择中
并尝试了DurandalTypescriptExample示例
此示例不会运行此错误:
无法找到该资源."
起初我决定只使用typescript更改我的viewmodels,然后在那个shell之后,但在这两种情况下我都遇到了这个错误:
这是我的shell.ts代码(我从这个示例中使用):
/// <reference path="../durandal/durandal.d.ts" />
import _router = module('durandal/plugins/router');
import app = module('durandal/app');
export var router = _router;
export function search() {
app.showMessage('Search not yet implemented...');
}
export function activate() {
return router.activate('welcome');
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
- JavaScript runtime error: 'exports' is undefined
Run Code Online (Sandbox Code Playgroud)
任何的想法?
如果可行,可行的解决方案是值得赞赏的.
thanx伙伴们让我们看看会发生什么.
我对DurandalTypescriptExample有同样的问题.但是,如果您只确保公开处置durandal requied变量,那么此项目中的代码演示了如何在viewmodel文件中实现typescript代码.至少激活函数和标题变量.
请参阅下面的代码示例:
/// <reference path="../../dts/knockout/knockout.d.ts" //>
export class ViewModel {
title: string = 'Home View';
MyTitle: KnockoutObservableString; //MyTitle can be referenced in home.html as vm.MyTitle
public activate() {
this.MyTitle = ko.observable(this.title + " with my ko title");
return true;
}
}
export var vm = new ViewModel();
//The Durandal plugin-interface variables
export var title = vm.title;
export var activate = function () { return vm.activate(); };
Run Code Online (Sandbox Code Playgroud)
由于我没有找到现成的项目来证明这一点,所以我必须自己制作.在github上查看我的Hot Towel项目版本:
https://github.com/Svakinn/TypeTowel
| 归档时间: |
|
| 查看次数: |
5518 次 |
| 最近记录: |