How to embed font to all page with nuxt js

后端 未结 5 1801
心在旅途
心在旅途 2021-01-04 12:51

I just embed google font to the global setting in nuxt.config.js

 link: [
      { rel: \'stylesheet\', href: \'https://fonts.googleapis.com/css?family=Roboto         


        
5条回答
  •  执笔经年
    2021-01-04 13:03

    you can do these steps: 1__define your font in as a custom varriable in a seprated file in your assests directory,for example variables.scss, like this:

    $body-font-family: Roboto;
    @import '~vuetify/src/styles/styles.sass';

    2__then in the nuxt.config.js,you should add a stylesheet link in the head, like this:

    head: {
      link: [
        { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Oswald|Libre+Baskerville&display=swap' }
      ]
    },

    3__then it is neccessary to enable treeshaking in the vuetify and set your customvariables,like this:

    vuetify: {
      customVariables: ['~/assets/variables.scss'],
      treeShake: true
    },

提交回复
热议问题