我是Angular2的新手,到目前为止我很享受,但有一个问题:打字.我无法弄清楚如何使用它们以及它们到底是什么.有些地方说使用打字,其他人说使用npm来安装定义.
我糊涂了!!
我正在尝试像下面的代码一样加载本地字体,但我不断收到Cannot find module '@/landing/fonts/Gotham-Bold.ttf'错误消息,并且不知道这条路径到底出了什么问题。
我的文件夹结构看起来像这样,我正在处理的代码是 LandingPage.tsx
import { createGlobalStyle } from 'styled-components';
import font from './fonts/Gotham-Bold.ttf'
const Gotham = createGlobalStyle`
@font-face {
font-family: 'Gotham';
font-style: normal;
font-weight: bold;
src:
url(${font}) format('truetype'),
}
`
Run Code Online (Sandbox Code Playgroud)