1
1

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 3 years have passed since last update.

【Nuxt.js】Nuxt.jsプロジェクトにプラグインを導入する

Last updated at Posted at 2021-01-29

Nuxt.jsで外部プラグインを導入する際の手順をまとめておきます。

1 . 追加したいプラグインをインストール(今回はvuejs-dialogを例にします)

npm i -save vuejs-dialog

package.jsonに追加されていることを確認!

package.json
"vuejs-dialog": "^1.4.2"

2 . pluginsフォルダ配下にファイルを作成する(ファイル名は任意)

※MacのコマンドなのでWindowsの方は読み替えて下さい。

touch plugins/vuejs-dialog.js

3 . 下記のようにプラグインをVueで使うことを宣言する

plugins/vuejs-dialog.js
import Vue from 'vue'
import VueDialog from 'vuejs-dialog'

Vue.use(VueDialog)

4 . 作成したplugins/vuejs-dialog.jsnuxt.config.jsに登録する

nuxt.config.js
plugins: [
    { src: '~/plugins/vuejs-dialog'}
  ],

これで各Vueファイルからプラグインを使用できます!!!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?