我通过 require
引用图像,并且我想从 Sprite 图像中裁剪图标。
const sprite = require('./sprite.png')
const crop = {left: 10, top: 50, width: 20, height: 40}
export const cartLogo = sprite({crop})
// How do I apply the crop to the sprite?
then
<Image source={cartLogo}/>
我了解了使用 {uri: 'url-to-image', Crop: {left: 10, top: 50, width: 20, height: 40}} 时如何在react-native中裁剪图像
in here 。如何使用 require
做到这一点?.
最佳答案
我知道 require('./sprite.png') 很快就会贬值。
所以最好的方法是管理它
image : {uri: ..., crop: {left: 10, top: 50, width: 20, height: 40}}
您也可以关注my post here.
如果您成功,请告诉我们
关于javascript - 在 React Native 中裁剪图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42242198/