gpt4 book ai didi

react-native - 如何使用 Image React-Native 组件的 getImage 处理错误?

转载 作者:行者123 更新时间:2023-12-04 15:50:27 25 4
gpt4 key购买 nike

我无法根据 react native image 上的文档实现.有人可以帮助我吗?

Image.getSize(this.props.data.thumbnail, (width,height) =>{
const win = Dimensions.get('window')
const ratio = win.width/width
this.setState( {
width: style.width,
height: height * ratio
})
})

最佳答案

有一个错误回调,您可以使用它来处理错误。

 Image.getSize(this.props.data.thumbnail, (width, height) =>
{
const win = Dimensions.get('window')
const ratio = win.width/width
this.setState({
width: style.width,
height: height * ratio
})
}, (error) =>
{
this.setState({ loading: false });
console.log( error );
});

关于react-native - 如何使用 Image React-Native 组件的 getImage 处理错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54040150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com