簡體   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