本文介绍一些RN的全局设置:
修改字体(全局)
class App extends React.Component {
componentWillMount(){
this.globalConfig()
}
globalConfig(){
let fontFamily
if (Platform.OS === 'ios' && parseInt(Platform.Version, 9) >= 9) {
fontFamily = 'PingFangSC-Medium' // 苹方中等
} else if (Platform.OS === 'ios') {
fontFamily = 'PingFangSC-Medium'
} else if (Platform.OS === 'android') {
fontFamily = '.PingFangSC-Medium'
}
const textGlobalStyle = {
style: {
fontFamily,
},
}
setCustomText(textGlobalStyle)
}
}
RN切换打包环境
切换后台,多次切换后台环境,切换打包环境好像是
react-native run-ios --scheme xxx
注释方法
一个标签的子节点内(非最外层)用 {} 包围要注释的部分:
var content = (
<Nav>
{/* 一般注释, 用 {} 包围 */}
<Person
/* 多
行
注释 */
name={window.isLoggedIn ? window.name : ''} // 行尾注释
/>
</Nav>
);
网友评论