[Nuxt.js]2.9以上 Google material icon(マテリアルアイコン)を使う

Advertisements
nuxtjsnuxt.js

久しぶりにみんな大好きGoogle fonts.のmaterial icon(マテリアルアイコン) をNuxt(@nuxt/cli v2.15.8)で使おうと思ったら、変なところでハマりました。
やり方は全部こちらに書いてありますが、インストールするパッケージを間違えたので備忘録としてまとめておきます。

Setup
Using Google Fonts in your Nuxt project

2.9以下はこちらを参照ください。

Advertisements

パッケージをインストール

nuxt-material-design-icons-iconfont
Nuxt Material Design Icons - iconfont Module. Latest version: 1.0.2, last published: 4 years ago. Start using nuxt-material-design-icons-iconfont in your projec...
yarn add nuxt-material-design-icons-iconfont
// Or npm:
npm install nuxt-material-design-icons-iconfont

nuxt.config.jsに追記

modules: [
  'nuxt-material-design-icons-iconfont',
],

head内linkへの設定は適用されませんでした。何でだろう。

    {
        rel: 'stylesheet',
        href: 'https://fonts.googleapis.com/icon?family=Material+Icons',
    },

vueファイルに書く

 <span class="material-icons">chevron_right</span>

参考
How to use material design icons in nuxt | stack overflow

スタイルの変更などはこちらで詳しく解説されています。
Material Icons(Google Font Icons)の使い方を解説!表示されない時に確認すべきポイントも

タイトルとURLをコピーしました