我正在尝试创建一个简单的 React Native 应用程序:
关于我应该如何去做的任何想法?
我给出this
了黑色的初始状态,但这似乎没有任何作用。
我想要发生的是在单击红色按钮时触发 makeRed,这将使文本变为红色。一旦我完成这项工作,我将添加更多颜色按钮。
谢谢!
请参阅下面的我的 App.js 代码。所有其他文件都保持默认状态。
import React, { Component } from 'react';
import {
AppRegistry,
Platform,
StyleSheet,
Text,
TextInput,
View,
Button
} from 'react-native';
export default class App extends Component<{}> {
constructor(props) {
super(props);
this.state = {
text: 'World',
color: 'black'
};
}
makeRed = () => {
this.setState({
color: 'red'
});
}
render() {
return (
<View style={styles.container}>
<Text style={[styles.welcome, {color: undefined}]}>
Hello, {this.state.text}!
</Text>
<TextInput …
Run Code Online (Sandbox Code Playgroud) 我刚刚从 v2 升级,css 不再是从我的 UI 隐藏 recaptcha 徽章的有效选项。这可以用 JavaScript 完成吗?