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

前端 未结 3 683
时光说笑
时光说笑 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条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 01:58

    You can export object itself:

    export default {
        googleClientID:'xxxx'
    };
    

    The difference is that in your case you will get brand new object every time you call exported function. In this case you will get the same object every time. Depends on what you need.

提交回复
热议问题