我正在处理我的第一个ES6
应用程序,angular2
并且在使用es7装饰器语法时无法使其工作.
import * as stylesheet from '../assets/styles/app.scss'; import $ from 'jquery'; import jQuery from 'jquery'; // export for others scripts to use window.$ = $; window.jQuery = jQuery; import './boot' import {AppComponent} from './app.component'
(function (app) { document.addEventListener('DOMContentLoaded', function () { ng.platform.browser.bootstrap(app.AppComponent); }); })(window.app || (window.app = {}));
import {Component} from 'angular2/core'; @Component({ selector: 'my-app', template: 'My First Angular 2 App
' }) export class AppComponent { constructor() { } }
{ "main": "index.js", "scripts": { "build": "npm-run-all clean prepare build:style build:app", "build:app": "browserify -e ./app/index.js -o ./dist/app.js", "build:production": "npm prune && npm install && npm run lint && npm test && npm run build", "build:style": "npm run build:semantic-ui; npm run copy:style", "build:semantic-ui": "gulp --gulpfile ./node_modules/semantic-ui/gulpfile.js build", "copy:style": "cp -r semantic/dist/* ./dist/styles", "clean": "rimraf ./dist/**/*", "lint": "jshint app/**", "prepare": "mkdir -p ./dist", "prestart": "npm run build", "pretest": "npm install", "screenshot": "node tests/screenshot.js", "serve": "static -p ${PORT:-5000} --gzip --host-address 0.0.0.0 ./", "start": "npm run serve", "test": "mocha --compilers js:babel-core/register tests", "watch": "PORT=${PORT:-5000} npm-run-all --parallel serve watch:app", "watch:app": "watchify -dv -e ./app/index.js -o ./dist/app.js", "watch:tests": "npm test -- -w" }, "devDependencies": { "browserify": "latest", "babel-core": "6.3.x", "babel-eslint": "^5.0.0-beta6", "babel-plugin-angular2-annotations": "3.0.x", "babel-plugin-transform-class-properties": "6.3.x", "babel-plugin-transform-decorators-legacy": "1.3.x", "babel-plugin-transform-flow-strip-types": "6.3.x", "babel-preset-es2015": "6.3.x", "babelify": "7.2.x", "babylon": "6.3.x", "csscritic": "https://github.com/cburgmer/csscritic.git", "jshint": "2.8.x", "mocha": "^2.3.4", "node-static": "0.7.x", "npm-run-all": "1.4.x", "pageres": "3.0.x", "rimraf": "2.4.x", "sassify": "0.9.x", "semantic-ui": "2.1.x", "watchify": "3.6.x" }, "dependencies": { "jquery": "latest", "babel-polyfill": "^6.3.14", "angular2": "^2.0.0-beta.0", "es6-promise": "^3.0.2", "es6-shim": "^0.33.13", "reflect-metadata": "^0.1.2", "rxjs": "^5.0.0-beta.0", "zone.js": "^0.5.10" }, "babel": { "presets": [ "es2015" ], "plugins": [ "angular2-annotations", "transform-decorators-legacy", "transform-class-properties", "transform-flow-strip-types" ] }, "browserify": { "transform": [ [ "babelify", { "presets": [ "es2015" ] } ], [ "sassify", { "auto-inject": true } ] ] }, "jshintConfig": { "esnext": true } }
EXCEPTION: Token must be defined! angular2-all.umd.js:29460 EXCEPTION: Token must be defined! angular2-all.umd.js:29451:14 STACKTRACE: angular2-all.umd.js:29451:14 BaseException@http://localhost:5000/node_modules/angular2/bundles/angular2-all.umd.js:4350:24 Key@http://localhost:5000/node_modules/angular2/bundles/angular2-all.umd.js:4924:20 KeyRegistry
这是怎么回事?我该如何解决这个问题?
将Angular2组件转换为ES6语法需要什么?
如何在没有装饰器语法的情况下编写angular2?
Blacksonic.. 5
在我的情况下,这是因为我给的课程bootstrap
是undefined
.
如果您的目标是制作Angular 2应用程序的骨架ES6版本,我创建了一个工作示例,其中所有内容都设置为工作并接受装饰器.
在我的情况下,这是因为我给的课程bootstrap
是undefined
.
如果您的目标是制作Angular 2应用程序的骨架ES6版本,我创建了一个工作示例,其中所有内容都设置为工作并接受装饰器.