Versuchen ES6 Importe mit Chrome, aber es scheint nicht zu funktionieren

Ich bin überlegt, von Dart bis ES6 aber Chrome scheint das nicht zu unterstützen, die neue import-statement, das ist wichtig für mich.

Ich das (export benannt) code von dieser Seite: http://www.2ality.com/2014/09/es6-modules-final.html

Versuchte ich es sogar mit

<module import="main"><module>

Bekomme ich die Fehlermeldung: "Unerwartetes token importieren"

Alle Informationen, wenn Sie es unterstützen, bevor die endgültige Version ?

code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>ES6</title>
</head>
<body bgcolor="blue">
  <script type="module" src="main.js"></script>
</body>
</html>

main.js

import { square, diag } from 'lib';
console.log(square(11)); //121
console.log(diag(4, 3)); //5

lib.js:

export const sqrt = Math.sqrt;
export function square(x) {
    return x * x;
}
export function diag(x, y) {
    return sqrt(square(x) + square(y));
}

InformationsquelleAutor der Frage Ray Hulha | 2016-02-19

Schreibe einen Kommentar