繁体   English   中英

defaultSource 不适用于 expo 发布

[英]defaultSource not working with expo publish

我有一个奇怪的defaultProfile实例不起作用。 下面是我创建的自定义组件。 它需要portrait道具,但如果该肖像不存在,它会回退到存储在我的assets文件夹中的默认个人资料图像。 现在,当我使用 Expo 进行热加载时,它会显示我的默认个人资料图片。 但是,每当我使用expo publish发布构建时,它都不会加载图像。 奇怪的是,我项目中的所有其他资产通常使用expo publish加载。 只有那些通过defaultProfile呈现的资产不起作用。 我在 iOS 上运行它。 此外,我已经尝试通过assetBundlePatterns中的app.json下载图像,但这并不能解决问题。 有任何想法吗?

import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import React, { useState } from 'react'
import { useTheme } from '@react-navigation/native'

const ResidentSelectorCell = (props) => {

    const { onPress, portrait, name, selected } = props

    const { colors, fonts } = useTheme()

    return (
        <TouchableOpacity style={styles.container}
        onPress={onPress}
        >
            <Image style={styles.image}
                source={portrait}
                defaultSource={require('../../../assets/images/defaultProfile.jpeg')}
            />
            <Text style={[styles.text, { color: colors.text, fontFamily: fonts.latoBold }]}
                numberOfLines={1}
                adjustsFontSizeToFit={true}
            >{name ? name : 'No Name'}</Text>
            <View style={[styles.icon, selected
                ? {borderWidth: 5, borderColor: colors.authAccent}
                : {borderWidth: 1, borderColor: colors.borderLight}]}

            />
        </TouchableOpacity>
    )
}

export default ResidentSelectorCell

const styles = StyleSheet.create({
    container: {
        flexDirection: 'row',
        alignItems: 'center',
        marginBottom: 30,
    },
    image: {
        height: 56,
        width: 56,
        borderRadius: 100,
        marginRight: 16
    },
    text: {
        marginRight: 'auto',
        fontSize: 18
    },
    icon: {
        height: 22,
        width: 22,
        borderRadius: 50
    },
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM