我试图在输入用户名后在react-native,native-base中按下按钮显示一个微调器。它不起作用。以下是我的步骤和代码:
步骤:
如果加载true渲染微调器,则加载其他屏幕。
constructor(props) {
super(props);
this.state = {
loading: true,
}
handleLoginPressed = async () => {
//some code
let resp = await tryAsk(this.state.sampleQuestion, this.state.username);
this.setState({
loading: false
});
}
render() {
if (this.state.fontsAreLoaded == true) {
if (this.state.isLoggedIn === true) {
if (this.state.loading === true){
<View><Spinner /></View>
}else{
return (
<Somescreen/>
);
}
}
答案 0 :(得分:2)
对我来说很好 这是使用NativeBase 2.3.6
<Content>
<Spinner />
<Spinner color="red" />
<Spinner color="green" />
<Spinner color="blue" />
</Content>
也适用于<View>
答案 1 :(得分:0)
您忘记了return
constructor(props) {
super(props);
this.state = {
loading: true,
}
handleLoginPressed = async () => {
//some code
let resp = await tryAsk(this.state.sampleQuestion, this.state.username);
this.setState({
loading: false
});
}
render() {
if (this.state.fontsAreLoaded == true) {
if (this.state.isLoggedIn === true) {
if (this.state.loading === true){
return <Spinner />
}else{
return (
<Somescreen/>
);
}
}