角度2示例错误

时间:2016-07-17 18:04:26

标签: angular browserify babeljs

运行我的angular 2应用程序时出错,这是我的app.js

import 'zone.js/lib/browser/zone-microtask';
import 'reflect-metadata';

import { Component, View, bootstrap } from 'angular2/angular2';
import { HelloComponent } from './hello.component';

@Component({
  selector: 'hello-app'
})
@View({
  directives: [HelloComponent],
  template: `
    <div>
      <hello-component></hello-component>
    </div>
  `
})
class HelloApp { }

bootstrap(HelloApp, []);

这是错误:

  

{[SyntaxError:/code/angular2-example/app.js:Unexpected token(7:0)   解析文件时:/ code/angular2-example/app.js] pos:190,loc:   位置{line:7,column:0},_babel:true,codeFrame:   '\ u001b [0m 5 | \ u001b [36mimport \ u001b [39m \ u001b [32m {\ u001b [39m]   HelloComponent \ u001b [32m} \ u001b [39m from   \ u001b [31m \'./ hello.component \'\ u001b [39m \ u001b [1m; \ u001b [22m \ n 6 |   \ n&GT; 7 |   \ u001b [7米@ \ u001b [27mComponent \ u001b [34米\ u001b [1分(\ u001b [22米\ u001b [39米\ u001b [32米{\ u001b [39米\ n   | ^ \ n 8 |选择器\ u001b [1分:\ u001b [22米   \ u001b [31m \'hello-app \'\ u001b [39m \ n 9 |   \ u001b [32m} \ u001b [39m \ u001b [34m \ u001b [1m] \ u001b [22m \ u001b [39m \ n 10 |   \ u001b [7米@ \ u001b [27mView \ u001b [34米\ u001b [1分(\ u001b [22米\ u001b [39米\ u001b [32米{\ u001b [39米\ u001b [0米”,   filename:'code / angular2-example / app.js',

但我没有看到它。拜托,你能帮我吗?我只是从角度2开始。

1 个答案:

答案 0 :(得分:0)

你的导入声明错了!

   import { Component, View, bootstrap } from 'angular2/angular2';

从&#34; @ angular / core&#39;

导入
   import {Component} from '@angular/core';
   import (bootstrap) from 'angular2/platform.browser';

从角度/核心导入组件,视图不再是角度

的类
相关问题