每当我尝试定位文本中心时,都会收到错误消息,即找不到变量“ center”。是我做错了还是做不正确?
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Image} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View>
<Text style={styles.titel}>Random Text</Text>
</View>
);
}
}
const styles = StyleSheet.create({
titel:{
color: 'black',
justifyContent: center,
alignItems: center,
}
});
答案 0 :(得分:3)
center
不是变量,它是字符串,因此您需要将其添加为
titel:{
color: 'black',
justifyContent: 'center',
alignItems: 'center',
}