我想改变宽度和高度<FlatList />
.
我将height
样式设置为当前<FlatList />
但它从未起作用.
我<FlatList />
绝不能改变高度.
这是我的render()
功能和风格.
render() {
const listData = [];
listData.push({ key: 0 });
listData.push({ key: 1 });
listData.push({ key: 2 });
listData.push({ key: 3 });
listData.push({ key: 4 });
return (
<View style={styles.container}>
<FlatList
data={listData}
renderItem={({item}) => {
return (
<View
style={{
width: 30, height: 30, borderRadius: 15, backgroundColor: 'green'
}}
/>
)
}}
horizontal
style={styles.flatList}
/>
</View>
);
}
const styles = StyleSheet.create({
container: { …
Run Code Online (Sandbox Code Playgroud) 我想调用fetch()
函数.
它适用于iOS但不适用于Android.
fetch('https://admin.leanpoint.com/Api/User/Login?user=srinu@mainpoint.dk', {
method: 'POST',
headers: {
'Authorization': 'Basic c3JpbnVAbWFpbnBvaW50LmRrOnNhaWJhYmE='
},
})
.then((res) => {
res.json().then((json) => {
alert(JSON.stringify(json))
})
})
.catch((err) => {
alert(JSON.stringify(err))
})
Run Code Online (Sandbox Code Playgroud)
在iOS上,它进入.then()
但在Android上它进入.catch()
并且err
是{}
.
它不适用于仿真器和真实设备.
任何帮助表示赞赏.^ _ ^
使用Axios的错误日志
当我使用fetch()
它时输入.catch()
{}.
我试过Axios
如下.
axios.post('https://admin.leanpoint.com/Api/User/Login?user=srinu@mainpoint.dk', null, {
headers: {
'Authorization': 'Basic c3JpbnVAbWFpbnBvaW50LmRrOnNhaWJhYmE='
},
timeout: 2000
})
.then((res) => {
console.log(res.data)
})
.catch((err) => {
console.log(err)
})
Run Code Online (Sandbox Code Playgroud)
并返回如下错误.
{ [Error: Network Error]
config:
{ …
Run Code Online (Sandbox Code Playgroud)