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?

【Vue3】does not provide an export named 'default'の対処方法

Posted at

簡単に残します。

環境:Vue3
記述:Composition API

エラーが起きた事例

jsファイルをapiフォルダ内に作成して、コンポーネントでimportしようとしたところ、タイトルのエラー発生

エラー発生時の記述

const getUser(fn) {
setTimeout(() => fn(sample),100)
}

エラー改善後の記述

export default {
getUser(fn) {
setTimeout(() => cb(sample),100)
}
}

原因
does not provide an export named 'default'

上記のエラーが出る場合は、composition APIのsetup記述ではなく、Option APIのexport default記述じゃなければ他のファイルにimportできないとの頃。

余談と感想
冷静に考えたらComposition APIは簡単に記述できるようになったものの、別のファイルにアクセス可能にするにはexport defaultで書かないとだめだよなと解決してから思いました。

同じくハマっている方が居たら、参考になると幸いです。
おやすみなさい。

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?