gyansangrah
New Coder
Hi Experts
I want to implement import and export module. For that, I have created a file "ExportClass.js". Here is the code
I am created another file "ImportClass.js" to import this module
After creating both JavaScript files, I have created the HTML file.
But the module is not called. Please help.
I want to implement import and export module. For that, I have created a file "ExportClass.js". Here is the code
JavaScript:
const person = {
name: 'Max'
};
export default person;
I am created another file "ImportClass.js" to import this module
JavaScript:
// JavaScript source code
import { person } from './ExportClass.js';
function Test() {
alert(person.name);
//exportClass.Print1();
}
After creating both JavaScript files, I have created the HTML file.
HTML:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="module" src="ImportClass.js"></script>
<script>
Test();
</script>
</head>
<body>
</body>
</html>
But the module is not called. Please help.