es6 模块导入

b.js

export function fun(){
    console.log("fun1")
}

export let person = {
    name:"devin",
    age:12
}

c.js

let a = 12
let fun = function(){
    console.log("function")
}

export default{
    a,fun
}

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="module" >
    // import * as util from './a.js';
    // //import {fun, person} from "./a.js";
    // console.log(util.fun(),util.person)
    // import a from './exportDefault';
    // a.show();
    // console.log(a.a);

    // import * as util from "./b.js"
    import c from "./c.js"
    // console.log(util.fun)
    console.log(c.a)
    c.fun()
    
</script>
</body>
</html>
发布了183 篇原创文章 · 获赞 18 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_38331049/article/details/105268295