0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Vue.js/JavaScript】export defaultとexportの違い

Posted at

変数、関数、処理の受け渡しに使用する双方の違いについてまとめました。

双方の主な違い

export default
渡せるのは1つのみ

export複数渡せる

export default

変数、定数、関数などの処理を1つの機能として渡すモジュール。

渡す

export default 処理

受け取る

import モジュール名 from 'ファイルパス'

// asで別名を付ける
変数名 as 変更後の名前

export

変数、定数などを複数渡せる。

渡す

export { 変数名1, 変数名2, 変数名3,,,}

受け取る

import { 変数名1、変数名3 } from 'ファイルパス'

// asで別名を付ける
 { 変数名1 as 変数名A', ,,}
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?