reactnativecn / react-native.cn

reactnative.cn home site.
http://reactnative.cn
Other
588 stars 507 forks source link

使用路由器跳转到控制两个TextInput分别显示的页面中,切换两个TextInput时placeholder内容不显示,而直接由index指向这个页面就没有问题? #216

Closed baguosiji closed 6 years ago

baguosiji commented 6 years ago

import React, { Component } from 'react'; import { Text, View, TextInput, Button, TouchableOpacity } from 'react-native';

export class Setting extends Component { constructor(props) { super(props); this.state = { selectGoodTag: 0, text1:'', text2:'', text3:'', text4:'', text5:'', text6:'', text7:'' }; }

render() { return (

this.setState({ selectGoodTag: 0 })}> 体系服务
    </TouchableOpacity>
    <TouchableOpacity title="VIP专区" onPress={() => this.setState({ selectGoodTag: 1 })}>
      <View style={{ alignItems:'center', justifyContent:'center', marginTop:20, padding:20 }}>
        <Text>VIP专区</Text>
      </View>
    </TouchableOpacity>
    {this.state.selectGoodTag === 0 ?
      <View>
        <View style={[{ height: 45, flexDirection: 'row' }]}>
          <View style={{ flex: 1, justifyContent: 'center' }}>
            <Text>厂商指导价</Text>
          </View>
          <View style={{ flex: 1, justifyContent: 'center' }}>
            <TextInput
              style={{ textAlign: 'right', color: '#333', paddingRight: 10 }}
              placeholder="请输入厂商指导价"
              placeholderTextColor="#ddd"
              onChangeText={(text) => {
                this.setState({ text1:text });
              }}
              value={this.state.text1}
              underlineColorAndroid="transparent"
            />
          </View>
        </View>
        <View style={[{ height: 45, flexDirection: 'row' } ]}>
          <View style={{ flex: 1, justifyContent: 'center' }}>
            <Text>市场零售价</Text>
          </View>
          <View style={{ flex: 1, justifyContent: 'center' }}>
            <TextInput
              style={{ textAlign: 'right', color: '#333', paddingRight: 10 }}
              placeholder="请输入市场零售价"
              placeholderTextColor="#ddd"
              onChangeText={(text) => {
                this.setState({ text2:text });
              }}
              value={this.state.text2}
              underlineColorAndroid="transparent"
            />
          </View>
        </View>
        <View style={[{ height: 45, flexDirection: 'row' }, ]}>
          <View style={{ flex: 1, justifyContent: 'center' }}>
            <Text>进货价</Text>
          </View>
          <View style={{ flex: 1, justifyContent: 'center' }}>
            <TextInput
              style={{ textAlign: 'right', color: '#333', paddingRight: 10 }}
              placeholder="请输入进货价"
              placeholderTextColor="#ddd"
              onChangeText={(text) => {
                this.setState({ text3:text });
              }}
              value={this.state.text3}
              underlineColorAndroid="transparent"
            />
          </View>
        </View>
      </View>
                : <View>
                  <View style={[{ height: 45, flexDirection: 'row' }, ]}>
                    <View style={{ flex: 1, justifyContent: 'center' }}>
                      <Text>市场零售价</Text>
                    </View>
                    <View style={{ flex: 1, justifyContent: 'center' }}>
                      <TextInput
                        style={{ textAlign: 'right', color: '#333', paddingRight: 10 }}
                        placeholder="请输入市场零售价"
                        placeholderTextColor="#ddd"
                        onChangeText={(text) => {
                          this.setState({ text4:text });
                        }}
                        value={this.state.text4}
                        underlineColorAndroid="transparent"
                      />
                    </View>
                  </View>
                  <View style={[{ height: 45, flexDirection: 'row' }, ]}>
                    <View style={{ flex: 1, justifyContent: 'center' }}>
                      <Text style={{ fontSize: 14 }}>批发价 <Text
                        style={{ fontSize: 12, color: 'red' }}
                      >(购买现金)</Text></Text>
                    </View>
                    <View style={{ flex: 1, justifyContent: 'center' }}>
                      <TextInput
                        style={{ textAlign: 'right', color: '#333', paddingRight: 10 }}
                        placeholder="请输入批发价"
                        placeholderTextColor="#ddd"
                        onChangeText={(text) => {
                          this.setState({ text5:text });
                        }}
                        value={this.state.text5}
                        underlineColorAndroid="transparent"
                      />
                    </View>
                  </View>
                  <View style={[{ height: 45, flexDirection: 'row' }, ]}>
                    <View style={{ flex: 1, justifyContent: 'center' }}>
                      <Text>赠送积分</Text>
                    </View>
                    <View style={{ flex: 1, justifyContent: 'center' }}>
                      <TextInput
                        style={{ textAlign: 'right', color: '#333', paddingRight: 10 }}
                        placeholder="请输入赠送积分"
                        placeholderTextColor="#ddd"
                        onChangeText={(text) => {
                          this.setState({ text6:text });
                        }}
                        value={this.state.text6}
                        underlineColorAndroid="transparent"
                      />
                    </View>
                  </View>
                </View>
            }
  </View>
);

} }