Javascript 应更改默认字体系列不起作用
我是一个新手!我在项目中使用了shoutem/ui。 我在修改默认fontFamily时遇到问题。这是我的代码,请检查,然后帮助我解决这个问题。 非常感谢各位Javascript 应更改默认字体系列不起作用,javascript,react-native,shoutem,Javascript,React Native,Shoutem,我是一个新手!我在项目中使用了shoutem/ui。 我在修改默认fontFamily时遇到问题。这是我的代码,请检查,然后帮助我解决这个问题。 非常感谢各位 const-theme=\u0.merge(getTheme(){ 默认字体:{ fontFamily:“Rubik Italic”, }, 'shoutem.ui.NavigationBar':{ “.清除”:{ 容器:{ 背景颜色:params.primaryColor, borderBottomColor:'透明', 位置:'相对
const-theme=\u0.merge(getTheme(){
默认字体:{
fontFamily:“Rubik Italic”,
},
'shoutem.ui.NavigationBar':{
“.清除”:{
容器:{
背景颜色:params.primaryColor,
borderBottomColor:'透明',
位置:'相对',
},
“shoutem.ui.Title”:{
颜色:'白色',
尺寸:16,
},
},
“.正常”:{
容器:{
位置:'相对'
},
'shoutem.ui.Button':{
'shoutem.ui.Icon':{
颜色:params.colorTextAlpha,
},
'shoutem.ui.Text':{
颜色:params.colorTextAlpha,
},
},
“shoutem.ui.Title”:{
颜色:params.colorText,
},
}
},
“shoutem.ui.Row”:{
“.fix”:{
水平方向:10,
填充垂直:10,
}
}
});代码>您要做的是覆盖主题变量
导入默认主题变量和getTheme函数:
import {
getTheme,
defaultThemeVariables,
} from '@shoutem/ui';
然后定义自定义变量:
const myThemeVariables = {
...defaultThemeVariables,
title: { fontFamily: 'MyFont' },
};
const myTheme = getTheme(myThemeVariables);
然后定义使用这些变量的自定义主题:
const myThemeVariables = {
...defaultThemeVariables,
title: { fontFamily: 'MyFont' },
};
const myTheme = getTheme(myThemeVariables);
您无法覆盖更多的defaultFont
设置,因此您必须明确
此外,还必须导入样式提供程序:
import { StyleProvider } from '@shoutem/theme';
并使用它来控制组件的样式:
render() {
return (
<StyleProvider style={myTheme}>
// your components here
</StyleProvider>
);
}
}
render(){
返回(
//您的组件在这里
);
}
}
描述问题,仅仅说你有问题并不能真正帮助我们。我做了上述代码,但我的应用程序中的所有组件仍然不能使用这种字体。我已经使用连接到我的项目中的所有组件,非常感谢兄弟。这对我有用。你救了我一天。