【问题标题】:different code but the output does not change when i test on a device不同的代码,但当我在设备上测试时输出不会改变
【发布时间】:2017-12-04 16:30:54
【问题描述】:

您好,我是 react native 的初学者,我按照所有指南将 react native 与原生基础一起使用,但每当我使用下面的示例代码测试应用程序时,我仍然会得到 ​​p>

" 欢迎使用 React Native,开始,编辑 index.android.js"

如您所见,代码和输出不匹配,您知道如何解决这个问题吗?

 导入 {Container, Content, Button, Icon} from 'native-base';
从'react-native'导入反应,{组件};
​​​
导出默认类 IconButtonExample 扩展组件 {
    使成为() {
        返回 (
            
                
                    
                        
                        家
                    

                <Button success iconRight>
                    Next
                    <Icon name="ios-arrow-forward" />
                </Button>

                <Button info>
                    Previous
                    <Icon name="ios-arrow-back" />
                </Button>

                <Button warning>
                    <Icon name="ios-star" />
                </Button>

                <Button danger>
                    <Icon name="ios-close-circle" />
                </Button>

                <Button style={{backgroundColor: '#384850'}} >
                    <Icon name="ios-search" style={{color: '#00c497'}}/>
                </Button>
            </Content>
        </Container>
    );
}

}

【问题讨论】:

  • index.android.js 里面有什么?
  • 上面的代码,但是每当我通过运行“react-native run-android”构建时,应用程序都不会更新它的视图
  • 如果是这种情况,我看不到您在哪里使用应用注册表:AppRegistry.registerComponent
  • 您显示的代码无效(除非 SO 损坏),它缺少一些开始标签和文本标签。打包程序崩溃或构建失败?这可能会导致显示不更新。
  • 无论我放在“index.android.js”中的任何示例代码都不会更新设备上的视图,并且没有任何错误。

标签: android reactjs react-native native-base


【解决方案1】:

您需要将上面发布的代码放在名为 index.android.js 的主文件中

您需要重新启动模拟器并重新捆绑应用程序

您可以在此处查看 React Native 项目的默认文件夹结构。

or read about it

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-07
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多