我正在尝试将 Shotem/ui 与指数一起使用,但在使用 Shotem/ui 文本输入组件时出现错误,我收到以下错误消息 fontFamily Rubik is not a system font and has not been loaded through Exponent.Font.loadAsync
但是,我加载了博客文章 https://blog.getexponent.com/using-react-native-ui-toolkits-with-exponent-3993434caf66#.iyiwjpwgu 中列出的所有自定义 Shotem 字体
使用 Exponent.Font.loadAsync 方法。
fonts: [
FontAwesome.font,
{'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf')},
{'Rubik-Black': require('./node_modules/@shoutem/ui/fonts/Rubik-Black.ttf')},
{'Rubik-BlackItalic': require('./node_modules/@shoutem/ui/fonts/Rubik-BlackItalic.ttf')},
{'Rubik-Bold': require('./node_modules/@shoutem/ui/fonts/Rubik-Bold.ttf')},
{'Rubik-BoldItalic': require('./node_modules/@shoutem/ui/fonts/Rubik-BoldItalic.ttf')},
{'Rubik-Italic': require('./node_modules/@shoutem/ui/fonts/Rubik-Italic.ttf')},
{'Rubik-Light': require('./node_modules/@shoutem/ui/fonts/Rubik-Light.ttf')},
{'Rubik-LightItalic': require('./node_modules/@shoutem/ui/fonts/Rubik-LightItalic.ttf')},
{'Rubik-Medium': require('./node_modules/@shoutem/ui/fonts/Rubik-Medium.ttf')},
{'Rubik-MediumItalic': require('./node_modules/@shoutem/ui/fonts/Rubik-MediumItalic.ttf')},
{'Rubik-Regular': require('./node_modules/@shoutem/ui/fonts/Rubik-Regular.ttf')},
{'rubicon-icon-font': require('./node_modules/@shoutem/ui/fonts/rubicon-icon-font.ttf')},
],
});
查看代码我找不到明显的修复 - 甚至无法找到样式设置为抛出错误的位置。
最佳答案
上面的代码似乎少了一行。尝试将此行添加到数组列表中:
{'Rubik': require('./node_modules/@shoutem/ui/fonts/Rubik-Regular.ttf')}
关于react-native - 在 Exponent react 原生框架中使用 ShoutemUI/TextInput 组件时出现字体加载错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41619776/