Kombination von Exporten in JavaScript
Man kann Standardexport und normale Exporte kombinieren:
export function func1() {
return '1'
}
export function func2() {
return '2'
}
export default function() {
return 'text';
};
Führen wir den Import durch:
import test, {func1, func2} from './test.js';
Prüfen wir die Funktionsweise der Standardfunktion:
let res = test();
console.log(res);
Prüfen wir die Funktionsweise der anderen Funktionen:
let res1 = func1();
let res2 = func2();
console.log(res1, res2);
Erstellen Sie ein Modul, das eine Funktion als Standard und noch mehrere weitere Funktionen exportiert.