What is the correct way to export a constant in ES6?

后端 未结 3 1046
有刺的猬
有刺的猬 2021-01-17 08:46

I\'m trying to break my entry file into components but I\'m not sure how to make the constant available to the import. This is what I\'ve tried so far and both seem to work:

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-17 08:52

    With considering all the above answers, you can also export your constant as well as a module in ES6:

    module.exports = yourConstant;
    

    and call it from your file:

    import yourConstant (JavaScript)

    require yourConstant (Node JS)

提交回复
热议问题