、、开关 开关需要两个属性 value 开关状态, onvaluechange获取开关状态
<Switch onValueChange={this.getdata} value={this.state.data} />
{this.state.data && (
<View>
<TextInput
onChangeText={dd => {
this.setState({
aa: dd
});
}}
/>
<Button
title="添加"
onPress={async () => {
await AsyncStorage.setItem("dd", this.state.aa);
}}
/>
<Button
title="删除"
onPress={async () => {
await AsyncStorage.removeItem("dd");
}}
/>
<Button
title="查询"
onPress={async () => {
const ddd = await AsyncStorage.getItem("dd");
alert(ddd);
}}
/>
</View>
//标题
static navigationOptions = ({ navigation }) => {
return {
title: navigation.getParam("name").title
};
};
//详情
<ScrollView>
<HTML
html={this.state.content}
imagesMaxWidth={Dimensions.get("window").width}
/>
</ScrollView>
//刷新列表
<FlatList
data={this.state.data}
renderItem={({ item }) => (
<TouchableHighlight
onPress={() => {
this.props.navigation.navigate("Detils", { name: item });
}}
>
<View style={{ borderBottomColor: "#ddd", borderBottomWidth: 1 }}>
<Text style={{ fontSize: 20 }}>{item.title}</Text>
</View>
</TouchableHighlight>
)}
refreshing={this.state.refreshed}
onRefresh={this.getFirst}
onEndReached={this.getNext}
onEndReachedThreshold={0.0001}
/>
getNext = () => {
this.setState({
page: this.state.page + 1
});
let api =
"https://cnodejs.org/api/v1/topics?page=" +
this.state.page +
"&tab=job&limit=20";
fetch(api)
.then(res => res.json())
.then(resJson =>
this.setState({
data: [...this.state.data, ...resJson.data]
})
)
.catch(err => {
alert(err);
});
网友评论