ES6 export all values from object

前端 未结 9 1782
梦谈多话
梦谈多话 2020-11-28 07:32

Say I have a module (./my-module.js) that has an object which should be its return value:

let values = { a: 1, b: 2, c: 3 }

// \"export values\         


        
9条回答
  •  春和景丽
    2020-11-28 08:25

    try this ugly but workable solution:

    // use CommonJS to export all keys
    module.exports = { a: 1, b: 2, c: 3 };
    
    // import by key
    import { a, b, c } from 'commonjs-style-module';
    console.log(a, b, c);
    

提交回复
热议问题