What is the best way to export an object literal with ES6/2015?

前端 未结 3 718
时光说笑
时光说笑 2021-02-05 01:24

Seemingly a very simple task...

export default function() {
    return {
        googleClientID:\'xxxx\'
    }
}

Is it the best way to export o

3条回答
  •  Happy的楠姐
    2021-02-05 01:41

    You can simply export an object

    export default { googleClientID:'xxxx' };
    

    A default export can be a function, a class, an object or anything else. This value is to be considered as the "main" exported value since it will be the simplest to import.

提交回复
热议问题