Help us understand the problem. What is going on with this article?

Nuxt.jsでGoogle Fontsを使う

More than 1 year has passed since last update.

nuxt.jsで作ったサイトにGoogle Fontsを使いたかった。
URL指定で個別に読み込む方法もあるが、今回はnuxt-webfontloaderを使った。

環境

Mojave 10.14.3(18D109)
node.js v10.11.0
yarn 1.10.1

手順

1. nuxt.jsでプロジェクト作成

$ yarn create nuxt-app プロジェクト名

2. nuxt-webfontloaderをインストール

$ yarn add nuxt-webfontloader

3. nuxt.config.jsを編集

nuxt.config.js
module.exports = {
// 省略
modules: [['nuxt-webfontloader']],
webfontloader: {
  google: {
    families: ['Josefin+Sans']
  }
},
// 省略
}

4. 導入したフォントを使ってみる

pages/index.vue
<template lang="pug">
  section
    h1 ABCDEFGHIJKLMNOPQRSTUVWXYZ
    h1 abcdefghijklmnopqrstuvwxyz
    h1 1234567890
</template>

<style lang="scss" scoped>
h1 {
  font-family: 'Josefin Sans', sans-serif;
}
</style>
$ yarn dev

localhost:3000にアクセス。
スクリーンショット 2019-03-20 11.10.40.png

ShoutaWATANABE
社内SE兼パソコン便利屋さん。 Ruby on Rails / Nuxt.js / vim / Google App Script / Python / AWS
https://shouta-w.hinaken.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした