HTML表格未在React Native应用中呈现

时间:2019-06-02 11:50:31

标签: react-native react-native-webview

我有一个我正在使用react-native-render-html的React Native应用程序。我从api那里得到样式表的html响应,但是当我从调试器控制台得到正确的响应时,它对应用程序什么也没有显示。我也尝试过react-native-webview但那也不起作用。这是我现在拥有的代码:

export class Toolbox extends Component {
constructor(props) {
super(props);
this.state = {
num4d: '',
result: null
}
}

searchResult = (num4d) => {
let formData = new FormData()
formData.append('num4d', num4d)
formData.append('magnum', 1)
formData.append('damacai', 1)


fetch('https://myapi', {
method: 'POST',
body: formData
}).then(response => response.text()).then(data => {
console.log(data)
this.setState({result: data})
})
.catch((error) => {
console.log(error)
})
.done()
}

render() {
const Divider = (props) => {
return <View {...props}>
  <View style={styles.line}></View>
</View>
}
}
return (
<Container>
  <Content>
    <Header>

      <Body style={{marginLeft:20}}>
        <Title>4D Number Stats & Detail</Title>
      </Body>
    </Header>
    <View>
      <View>
        <Left>
          <Item>
            <Icon name="ios-search" />
            <TextInput placeholder="Number" keyboardType="number-pad" onChangeText={(text)=> this.setState({num4d:
              text})} />
          </Item>
        </Left>
        <Right>
          <Button onPress={()=> this.searchResult(this.state.num4d)}><Text
              style={{ color: '#fff', fontSize: 18 }}> Search </Text></Button>
        </Right>
      </View>
      <ScrollView style={{ flex: 1 }}>
        <HTML html={this.state.result} />
      </ScrollView>
      </Body>
      </CardItem>
      </Card>
    </View>


    </View>
  </Content>
</Container>

0 个答案:

没有答案