ES6 export default function

前端 未结 3 817
臣服心动
臣服心动 2021-02-04 03:46

can I export more than one function per file ? it seems like when I do that , the second function ovverides the first one ,

example : in my index.js file

3条回答
  •  天命终不由人
    2021-02-04 04:49

    You can use named export instead of default:

    export function aFnt(){
        console.log("function a");
    }
    export function bFnt(){
        console.log("function b");
    }
    

    and import it like:

    import {aFnt, bFnt} from "./index";
    

提交回复
热议问题