我正在尝试使用所有新工具(jspm 0.17.0-beta.40)设置Angular 2应用程序。
我正在转发tsconfig.json
模块。这是{
"compileOnSave": false,
"compilerOptions": {
"target": "ES5",
"module": "System",
"moduleResolution": "Node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"rootDir": "../"
}
}
:
import
问题出在ES6 import { Component, ViewEncapsulation, AfterViewInit } from '@angular/core';
上。在这样的事情发生之后:
core_1.Component
使用它将是:
"TypeError: core_1.Component is not a function
at Object.execute (...app/app.component.js:32:24)
at E (...jspm_packages/system.js:4:7541)
at S (...jspm_packages/system.js:4:6746)
at S (...jspm_packages/system.js:4:6646)
at S (...jspm_packages/system.js:4:6646)
at x (...jspm_packages/system.js:4:6102)
at ...jspm_packages/system.js:5:6612"
但遗憾的是,运行该应用的浏览器无法识别它。
ViewEncapsulation
使用System
时会出现相同类型的错误。
这是转发到CommonJS
模块的时候。
使用import html from './app.component.html';
模块进行透明工作(应用程序通过此步骤)。
我无法使用它,因为我使用
meta
使用以下meta: {
"*.html": {
"loader": "text"
},
}
配置:
Error: No template specified for component AppComponent
哪个失败并显示错误
import java.util.*;
public class Prueba {
public static void main(String[] args) {
String currency = "USD";
System.out.println(findCurrencyRate(currency));
}
public static double findCurrencyRate(String Currency) {
String text = "EUR 1.65 \n USD 8.56 \n YEN 0.34";
Scanner file = new Scanner(text);
file.useLocale(Locale.US);
while (file.hasNextLine()) {
String line = file.nextLine();
Scanner linea = new Scanner(line);
linea.useLocale(Locale.US);
if (linea.next().equals(Currency)) {
double currencyValue = linea.nextDouble();
return currencyValue;
}
}
}
}
我尝试过切换JSPM和System的版本。
显然,系统0.20版本中引入的更改会导致此问题。
有关如何处理此事的任何想法?
答案 0 :(得分:4)
是的,这是SystemJS 0.20中的一个更改,其中不再支持非ES模块的命名导出,以便与ES模块和CommonJS之间的NodeJS中的互操作方式保持一致,这只是提供与默认值的兼容性导入表单 - import module from 'module'
(相当于import {default as module} from 'module'
)。
由于Angular是从一个不是ES模块本身的UMD bulid加载的,因此不支持指定的导出。
以下配置可用于告诉SystemJS将Angular核心模块视为具有命名导出的ES模块:
meta: {
'@angular/core': { esModule: true }
}