Javascript 如何在react native+;的导航选项卡中使用自定义字体;博览会?
通常,我可以为文本加载和呈现自定义字体,但当我尝试为导航栏指定字体系列时,会出现错误:“fontfamily‘poetsenone’不是系统字体,并且尚未通过font.Loadsync加载 我已使用font.Loadasync将字体加载到我的根目录compent@app.js中Javascript 如何在react native+;的导航选项卡中使用自定义字体;博览会?,javascript,react-native,Javascript,React Native,通常,我可以为文本加载和呈现自定义字体,但当我尝试为导航栏指定字体系列时,会出现错误:“fontfamily‘poetsenone’不是系统字体,并且尚未通过font.Loadsync加载 我已使用font.Loadasync将字体加载到我的根目录compent@app.js中 // homescreen.js: static navigationOptions = { title: 'Scan', tabBarOptions: { labelStyle: { fo
// homescreen.js:
static navigationOptions = {
title: 'Scan',
tabBarOptions: {
labelStyle: {
fontSize: 20,
fontFamily: "poetsenone"
},
tabStyle: {
},
style: {
marginTop: 23,
backgroundColor: '#423D3D',
},
}
};
//app.js
export default class App extends React.Component {
componentDidMount() {
Font.loadAsync({
'poetsenone': require('./assets/fonts/poetsenone.ttf')
});
}
render() {
return (
<AppContainer />
);
}
}
//homescreen.js:
静态导航选项={
标题:“扫描”,
选项卡选项:{
标签样式:{
尺寸:20,
Fontsenone家族:“poetsenone”
},
标签样式:{
},
风格:{
玛金托普:23,
背景颜色:“#423D3D”,
},
}
};
//app.js
导出默认类App扩展React.Component{
componentDidMount(){
Font.loadAsync({
“poetsenone”:需要(“./assets/font/poetsenone.ttf”)
});
}
render(){
返回(
);
}
}
app.js不是典型的顶级组件吗?发生了什么事?删除loadAsync中“poetsenone”周围的引号,它应该可以工作。我可以确认这在我的情况下是有效的。即使我使用了stacknavigator,我也无法正确使用字体名称周围的引号。按照建议删除它们,它就可以工作了。