暴露模块

40 阅读1分钟
分别暴露

m1.js

export let shool='尚硅谷';
export function teach(){
console.log("我们试试看");
}

html

<script type="module">
import * as m1 from "m1.js"

</script>

统一暴露

m2.js

let shool='尚硅谷';
function teach(){
console.log("我们试试看");
}

export {school,teach};

html

<script type="module">
import * as m1 from "m2.js"

</script>

默认暴露

m3.js

let shool='尚硅谷';
function teach(){
console.log("我们试试看");
}

export default {
shool:'尚硅谷',
change:function(){
console.log("我们试试看");
}
};

html

<script type="module">
import * as m1 from "m3.js"

</script>