在设备上运行时出现这样的错误“ 按钮的标题属性必须是字符串 - 反应原生”
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
Button,
View
} from 'react-native';
export default class sample extends Component {
render() {
return (
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}>
title="Press Me"
</Button>
);
}
_handlePress() {
console.log('Pressed!');
}
}
AppRegistry.registerComponent('sample', () => sample);
原文由 Ravindhiran 发布,翻译遵循 CC BY-SA 4.0 许可协议
我认为您太早关闭了 Button 标记。
只需在title属性后关闭标签