【发布时间】:2019-03-17 23:40:36
【问题描述】:
** 我在添加按钮时遇到了一些问题!**
在应用程序中出现了错误
java.lang.string 不能转换为 com.facebook.react.uimanager.accessibility DelegateUtil$accessibilityRole
我的简单代码
import React, { Component } from "react";
import { StyleSheet, TextInput, View, Button, Text } from "react-native";
export default class App extends Component {
state = {
placeName: ""
};
placeNameChangeHandler = val => {
this.setState({
placeName: val
});
};
onPressLearnMore = () => {
alert("Pressed");
};
render() {
return (
<View style={styles.container}>
<Button
onPress={this.onPressLearnMore}
title="Learn More"
color="#841584"
/>
<TextInput
style={{
width: 300,
borderBottomWidth: 1,
borderBottomColor: "#333"
}}
placeholder="Enter Name.."
value={this.state.placeName}
onChangeText={this.placeNameChangeHandler}
/>
</View>
);
}
【问题讨论】:
-
那么如果你删除
Button你的代码可以正常工作吗? -
@Think-Twice 我知道这无关!但那是我展示的!
-
@JoseVf 是的!这是工作,太奇怪了
-
@Gha 你使用的是哪个版本的 react-native?
-
@Think-Twice "react-native": "0.57.3"
标签: javascript reactjs react-native redux