加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

typescript – 模块’“angular2 / angular2”’没有导出成员’F

发布时间:2020-12-17 07:19:01 所属栏目:安全 来源:网络整理
导读:我正在关注官方Angular2网站上的教程. https://angular.io/docs/js/latest/guide/displaying-data.html 这是我的.ts文件: /// reference path="typings/angular2/angular2.d.ts" /import {Component,View,bootstrap,For} from 'angular2/angular2';@Compone
我正在关注官方Angular2网站上的教程.

https://angular.io/docs/js/latest/guide/displaying-data.html

这是我的.ts文件:

/// <reference path="typings/angular2/angular2.d.ts" />
import {Component,View,bootstrap,For} from 'angular2/angular2';

@Component({
    selector: 'display'
})
@View({
    template: '<p>name: {{myName}}</p>' +
                '<p>Friends:</p>' +
                '<ul>'+
                 '<li *for="#name of names">'+
                    '{{name}}'+
                 '<li>'+
                '<ul>',directives: [For]
})
class DisplayComponent{
    myName: string;
    names: Array<string>;

    constructotr(){
        this.myName = "Alice";
        this.names = ["Winston","Alex","Shannon","Irizu"];
    }
}

bootstrap(DisplayComponent);

这是我的HTML:

<html>
<head>
        <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
        <script src="https://jspm.io/system@0.16.js"></script>
        <script src="https://code.angularjs.org/2.0.0-alpha.23/angular2.dev.js"></script>
</head>
<body>
    <display></display>
    <script>
      System.import('show-properties');
    </script>
</body>

</html>

我已经安装了angular2,Rx和es6-promise.

仍然存在错误.

message TS6042: Compilation complete. Watching for file changes.
message TS6032: File change detected. Starting incremental
compilation… show-properties.ts(2,37): error TS2305: Module
‘”angular2/angular2″‘ has no expo rted member ‘For’. message TS6042:
Compilation complete. Watching for file changes.

更新

这是我更新的.ts代码:

/// <reference path="typings/angular2/angular2.d.ts" />
import {
 ComponentAnnotation as Component,ViewAnnotation as View,NgFor
} from 'angular2/angular2';



@Component({
    selector: 'display'
})
@View({
    template: '<p>name: {{myName}}</p>' +
                '<p>Friends:</p>' +
                '<ul>'+
                 '<li *ng-for="#name of names">'+
                    '{{name}}'+
                 '<li>'+
                '<ul>',directives: [NgFor]
})
class DisplayComponent{
    myName: string;
    names: Array<string>;

    constructotr(){
        this.myName = "Alice";
        this.names = ["Winston","Irizu"];
    }
}

bootstrap(DisplayComponent);

angular2.d.ts仍然是alpha 26.

现在没有错误消息,我可以看到

名称:
好友:

但是没有插入任何值.
我收到一条错误消息:

show-properties.ts(7,2): error TS2348: Value of type ‘typeof
ComponentAnnotation ‘ is not callable. Did you mean to include ‘new’?
show-properties.ts(10,2): error TS2348: Value of type ‘typeof
ViewAnnotation’ is not callable. Did you mean to include ‘new’?
message TS6042: Compilation complete. Watching for file changes.

您的问题是文档不同步.如果您最近按照文档进行安装,那么它将安装最新版本alpha26的类型,其中包含许多破坏的更改.该文档使用该版本代码的a23版本.你也可以

1)将您的打字更新为与v23匹配的旧版本,即find it here.复制内容并将其替换为./typings/angular2/angular2.d.ts.

2)将角度脚本升级到alpha 26并修复几件事.

>现在是NgFor,如果现在是NgIf
> * for现在是* ng-for,* if if now * ng-if …
> injectables(如果您打算在指令设置中使用)现在是appInjector
>使用相同的tsd查询xxx –action install命令为es6-promise,rx和rx-lite安装输入.

Demo – 23

Demo – 26

你也可以使用angular-class webpack starter的启动.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读