
お知らせ
2023.12.5(Tue)
目次
こんにちは、樋口です。
今回は、Nuxt.jsからライブラリを読み込むだけで簡単にマウスカーソルのエフェクトを追加できるvue-cursor-fxについてご紹介します。
今回は下記ライブラリを使用して説明をしていきます。
初めにコマンドプロンプトで、使用するNuxt.jsのプロジェクトフォルダまで移動します。移動後、以下のコマンドを実行します。
これで対象のプロジェクトに、ライブラリを追加することができました。次に実際のライブラリの使用方法について解説していきます。
モジュールの導入が完了しましたら次は、「plugins」フォルダ内に「vue-cursor-fx.js」のファイルを作成します。次に、vue-cursor-fx.jsに下記内容を記載し保存を行います。
import Vue from 'vue' import CursorFx from '@luxdamore/vue-cursor-fx' import '@luxdamore/vue-cursor-fx/dist/CursorFx.css' Vue.use(CursorFx)
次に、nuxt.config.jsに先ほど作成したファイル使用の宣言の追加を行います。
export default { mode: 'universal', ・・・・・ plugins: [ { src: '@/plugins/vue-cursor-fx', mode: 'client' }, ← 記載を追記 ], // 終了 ・・・・・ }5行目:
今回は下記のプロジェクト構成で作業を行っていきます。
今回サンプル用に作成した、Vueファイルを下記に記載します。
– index.vue
<template> <div class="samaple__conntents"> <div style="margin-top: 20px;"> <h1>vue-cursor-fxプラグインサンプル</h1> </div> <div style="margin-top: 20px;"> <cursor-fx color="#39B509" color-hover="#acf98e"></cursor-fx> </div> </div> </template> <script> export default { data() { return { count: 0, } }, } </script> <style> .samaple__conntents { margin: 0 auto; min-height: 100vh; justify-content: center; align-items: center; text-align: center; } </style>
今回紹介したライブラリを使用すれば、簡単にマウスへのエフェクトを追加できます。ぜひ機会ありましたら、試してみてください。
今後もNuxt.jsでの便利ライブラリについて紹介していけたらと思っています。
それではまた。
《関連記事》
·
prettier/prettier」が発生したときの対処法