Skip to content

选择图片出base64编码,无法正常显示 #7

@xiaolieask

Description

@xiaolieask

选择一张图片之后,设置返回base64编码,将base64编码放到图片中,图片无法正常显示

<View style={{
                width: 160,
                height: 36,
                backgroundColor: 'hsl(190,50%,70%)',
                paddingHorizontal: 16,
                paddingVertical: 8,
                borderRadius: 8
            }} onTouchEnd={() => {
                launchImageLibrary({ mediaType: 'photo', selectionLimit: 1, maxWidth: 360, maxHeight: 100, includeBase64: true, quality: 0.5 }, (data) => {
                    const { base64 = '', type = '' } = data.assets[0]
                    let auri = `data:image/png;base64,${base64}`
                    setUri(auri)
                })
            }}>
                <Text style={{ width: '100%', height: '100%', fontWeight: 'bold', textAlign: 'center' }}>选择</Text>
            </View>
            <Image
                style={{ width: 300, height: 300 }}
                source={{
                    uri: uri
                }}></Image>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions