LoginSignup
1

More than 5 years have passed since last update.

Javascriptのexportとimport

Posted at

modelを作ってexportする

// exportする側
// constを作成
const exampleModel1 = {
    object: {
        prop1: 'prop1',
        prop2: 'prop2',
        prop3: 'prop3',
    }
};
const exampleModel2 = {
    object: {
        prop4: 'prop4',
        prop5: 'prop5',
        prop6: 'prop6',
    }
};
function example(x) {
  return x * x * x;
}
// 色々export出来る
export { exampleModel1, exampleModel2, example }



// importする側※exampleModel1だけimportの場合
import { exampleModel1 } from '/path/to/file';

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1