Rav*_*ran 12 reactjs react-native
虽然在设备上运行得到这样的错误" 按钮的标题支柱必须是一个字符串 - 反应原生 "
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);
Run Code Online (Sandbox Code Playgroud)
Fre*_*bda 12
我认为你太早关闭了Button标签.
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}> // <-- closed tag here
title="Press Me"
</Button>
Run Code Online (Sandbox Code Playgroud)
只需在title属性后关闭标记即可
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}
title="Press Me"
>
Press Me
</Button>
Run Code Online (Sandbox Code Playgroud)
小智 5
按钮名称应与标题关键字一起编写
例子 :
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}
title="Press Me"
>
</Button>
Run Code Online (Sandbox Code Playgroud)
Button 标签内的 title="Press Me"
| 归档时间: |
|
| 查看次数: |
17290 次 |
| 最近记录: |