html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<script type="module">
import hello from "./js/bbb.js";
console.log(12)
var hungry = "hippo";
function awesome() {
console.log(11)
console.log(
hello( hungry ).toUpperCase()
);
}
awesome();
</script>
</body>
</html>
bbb.js
function hello(who) {
return "Let me introduce: " + who;
}
export hello;
报错如下:
解决方式:
1、改成default导出
把 export hello; 改为 export default hello;
2、 使用{} 导出,但是引入方式也需要修改
ok,解决了