加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在react-native中尝试使用Button时出错

发布时间:2020-12-15 05:07:40 所属栏目:百科 来源:网络整理
导读:制作一个简单的反应原生程序时,我无法得到 Button组件工作.我总是在react-native run- android之后得到的错误 java.lang.String cannot be cast to com.facebook.react.uimanager.AccessibilityDelegateUtil$AccessibilityRole 当我省略按钮时,一切正常,我可
制作一个简单的反应原生程序时,我无法得到< 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版本中出错.

init较低版本

react-native init --version="react-native@0.55.0" YOUR_APP_NAME

在那之前尝试这个

<Button
    onPress={() => alert('hi')}
    title="Press Me"
 >
   Press Me
</Button>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读