【发布时间】:2019-02-15 09:49:04
【问题描述】:
我试图让cropWidth 与它的父级宽度相同,但是当我使用字符串时,我得到了这个错误:unrecognized selector sent to instance。代码如下:
<RkCard style={{width:'80%', marginLeft: 40, marginBottom: 50, backgroundColor:'#f5f5f5', position:'relative', shadowColor: 'black', shadowOffset: {width: 10, height: 10}, shadowOpacity: 1, shadowRadius: 2, elevation: 5}}>
<ImageZoom cropWidth={'100%'} <-- string here, error is thrown
cropHeight={300}
imageWidth={300}
imageHeight={300}
style={{left: 0, alignSelf:'center', justifyContent: 'center', alignItems: 'center', backgroundColor:'#D3D3D3',}}>
<FastImage rkCardImg source={{uri:`https://www.example.com/profiles/uploads/${item.images}`,
headers:{ Authorization: 'someAuthToken' },
priority: FastImage.priority.high,
}}
resizeMode={FastImage.resizeMode.contain}
style={{width: '100%', height: 300, left: 0, alignSelf:'center', justifyContent: 'center', alignItems: 'center'}}/>
</ImageZoom>
</RkCard>
如果我使用整数,那么错误就会消失,因此它可能只接受那些。有没有办法可以使用字符串将宽度设置为与其父级相同?
【问题讨论】:
标签: css string reactjs react-native jsx