ES6导入模块运行非扩展功能

时间:2020-06-10 20:08:48

标签: javascript ecmascript-6 import module export

我有两个文件:a.js和b.js 我将a导入b。 我将b.js包含在index.html

即使我仅导出了test函数而不导出了test2,为什么test2函数仍运行。 https://codesandbox.io/s/blissful-sun-rrmnx?file=/src/a.js

// a.js

function test(){
  alert("Test")
}
function test2(){
  alert("test2")
}
test2();

export {test} 

// b.js

import { test } from './a.js';
test()

0 个答案:

没有答案