Home > front end >  ES6 modular mutual export import, according to the video interpretation, but an error?
ES6 modular mutual export import, according to the video interpretation, but an error?

Time:10-15

A. s
 export let x=16; 
Export the let y=18;

B.j s
 import {x, y} from "./a. s 
"
Export const info=()=& gt; {
The console. The log (x);
The console. The log (y);
}

C. HTML
 & lt; ! DOCTYPE html> 

<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
Document

<body>
Teaching video

Import from {info} "./B.j s ";
Info ();
</script>


Error message:

CodePudding user response:

Type="module" is not allowed to cross domain
Approach: in local structures, a server, the live - server, for example,
Vscode console installation:
NPM install - g live - server
Can be run directly after the success of the installation:
Live - server

Specific reference: https://www.jianshu.com/p/6661aaebf412
  • Related