How do I add a Google Font to a VueJS Component?

前端 未结 7 2087
离开以前
离开以前 2021-02-03 20:42

I\'ve been trying for an hour to find a way to import a Google Font into a VueJS Component, but I cannot seem to find a solution, nothing worked yet, not even the stuff from pre

7条回答
  •  萌比男神i
    2021-02-03 21:33

    I am currently doing it like the following:

    • Install the typeface of the font via npm (eg: npm install --save typeface-source-sans-pro)
    • Import the typeface in the component (import 'typeface-titillium-web';)
    • Use the font-face in the component (font-family: 'Titillium Web', sans-serif;)

    Keep in mind that with this the font gets self-hosted. So you don't have the support of the cached fonts on a cdn any more.

提交回复
热议问题