如何使用反应原生图像onError获取错误消息?
发布时间:2020-12-15 20:19:01 所属栏目:百科 来源:网络整理
导读:我使用react本机v0.44图像组件为 android,但图像无法加载,代码: View style={styles.slide1} key={index} Image style={styles.image} resizeMode = 'contain' onError = {(e)={ console.log(e) }} source={{uri:`http://i01.appmifile.com/webfile/globali
我使用react本机v0.44图像组件为
android,但图像无法加载,代码:
<View style={styles.slide1} key={index}> <Image style={styles.image} resizeMode = 'contain' onError = {(e)=>{ console.log(e) }} source={{uri:`http://i01.appmifile.com/webfile/globalimg/hk/cms/92247F5D-CC6E-273F-5710-841E891CB96F.jpg`}} /> </View> 图像无法显示,onError句柄获取错误,但如何知道加载图像中的错误? 解决方法
错误包含nativeEvent及其错误.
这样做: onError={({nativeEvent: {error}}) => { console.log(error); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |