制作一个简单的反应原生程序时,我无法得到< Button>组件工作.我总是在react-native run-
android之后得到的错误
java.lang.String cannot be cast to
com.facebook.react.uimanager.AccessibilityDelegateUtil$AccessibilityRole
当我省略按钮时,一切正常,我可以单击文本就好了.
代码:
import React,{Component} from 'react'; import {Platform,StyleSheet,Text,View,Button } from 'react-native'; type Props = {}; export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <Button onPress={()=>console.log('hi')} title="go"/> <Text onPress={()=>console.log('hi')}>Welcome to React Native!</Text> </View> ); } }
一些依赖:
"dependencies": { maar eens alles goed staat hoop ik gewoon dat de miserie gedaan is,cf "react": "16.6.0-alpha.8af6728","react-native": "0.57.3" },
我刚刚在0.55版本上测试了你的代码.这完全正确,工作得很好.
我可能会在您的react-native版本中出错.
我可能会在您的react-native版本中出错.
init较低版本
react-native init --version="react-native@0.55.0" YOUR_APP_NAME
在那之前尝试这个
<Button onPress={() => alert('hi')} title="Press Me" > Press Me </Button>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。