gpt4 book ai didi

javascript - 如何将不可变 js 导入 angular 2 (alpha)?

转载 作者:太空狗 更新时间:2023-10-29 17:50:53 24 4
gpt4 key购买 nike

我试过:

import {Component, Template, bootstrap} from 'angular2/angular2';
import {Immutable} from 'immutable/immutable';

@Component({
selector: 'my-app'
})
@Template({
inline: '<h1>Hello {{ name }}</h1>'
})

class MyAppComponent {
constructor() {
this.name = 'Alice';
this.wishes = Immutable.List(['a dog', 'a balloon', 'and so much more']);
console.log(this.wishes);
}
}

bootstrap(MyAppComponent);

但是 Immutable 最终成为未定义的。然后我尝试了:

import {Component, Template, bootstrap} from 'angular2/angular2';
import {Immutable} from 'immutable/immutable';

@Component({
selector: 'my-app'
})
@Template({
inline: '<h1>Hello {{ name }}</h1>'
})

class MyAppComponent {
constructor(im: Immutable) {
this.name = 'Alice';
this.wishes = im.List(['a dog', 'a balloon', 'and so much more']);
console.log(this.wishes);
}
}

但随后我得到 Cannot resolve all parameters for MyAppComponent。有人可以帮我吗?是的,我已将 immutable 文件夹添加到 System.paths。会不会是 Immutable 不能以 ES6 的方式导入?

最佳答案

这是一个小错误。我不得不改变

import {Immutable} from 'immutable/immutable';

import Immutable from 'immutable/immutable';

关于javascript - 如何将不可变 js 导入 angular 2 (alpha)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29527024/

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