将Angular2组件转换为ES6语法需要什么? [英] What do I need to convert my Angular2 component to ES6 syntax?

查看:149
本文介绍了将Angular2组件转换为ES6语法需要什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的入口点

Here is my entry point

import * as stylesheet from '../assets/styles/app.scss';

import jQuery from '../node_modules/jquery/dist/jquery';
import $ from '../node_modules/jquery/dist/jquery';

import {bootstrap}    from './boot'
import {AppComponent} from './app.component'

bootstrap(AppComponent);



app.component.js



作品

app.component.js

This works

(function (app) {
    app.AppComponent = ng.core
        .Component({
            selector: 'my-app',
            template: '<h1>My First Angular 2 App</h1>'
        })
        .Class({
            constructor: function () {
            }
        });
})(window.app || (window.app = {}));



问题



我试图使用答案来自如何在没有装饰器语法的情况下编写angular2?,没有成功。


  • 如何摆脱 IIFE 并使用 ES6 语法

  • How do I get rid of the IIFE and use ES6 syntax?

推荐答案

使用以下插件:'angular2-annotations','transform-decorators-legacy','transform-class-properties','transform-flow-strip-types' there不需要转换语法。

If you are using Babel and use the following plugins: 'angular2-annotations', 'transform-decorators-legacy', 'transform-class-properties', 'transform-flow-strip-types' there is no need to convert the syntax.

您还可以在工作示例

这篇关于将Angular2组件转换为ES6语法需要什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆