我正在尝试使用.otf
项目目录中本地文件中的字体来设置 Stripe Elements 提供的信用卡表单输入中的文本样式。
由于这是一个 React 项目,我一直在使用该react-stripe-elements
库。我一直在参考以下文档:
这是我尝试通过文档fonts
中指定的道具传递来使用所需字体的地方:react-stripe-elements
<Elements
fonts={[
{
family: 'geog',
src: 'url(../../../shared/styles/fonts/Geogtq-Rg.otf)',
style: 'normal',
weight: '400',
},
]}
>
<StripeCCForm />
</Elements>
使用此代码,我收到以下错误:
Invalid src value in font configuration: ../../../shared/styles/fonts/Geogtq-Rg.otf. URLs have to start with 'https://' or 'data:'
我的印象是该src
值可能是本地字体的相对路径,所以我很困惑为什么会收到此错误。任何见解将不胜感激!