Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React Native:我在显示页面中获取原始数据_Javascript_Api_React Native - Fatal编程技术网

Javascript React Native:我在显示页面中获取原始数据

Javascript React Native:我在显示页面中获取原始数据,javascript,api,react-native,Javascript,Api,React Native,我试图在我的仪表板页面中显示员工姓名。数据正在显示,但显示的是原始数据。我能知道怎么解决它吗 API代码(获取URL) 我在邮递员登记的API结果 呈现数据 {this.state.view_access == false ? <NoAccessScreen></NoAccessScreen> : this.state.isLoading

我试图在我的仪表板页面中显示
员工姓名
。数据正在显示,但显示的是原始数据。我能知道怎么解决它吗

API代码(获取URL)

我在邮递员登记的API结果

呈现数据

 {this.state.view_access == false
                            ? <NoAccessScreen></NoAccessScreen>
                            : this.state.isLoading
                                ? <View style={[components.alignCenter, components.justifyCenter, components.pad_10]} >
                                    <ActivityIndicator />
                                </View>
                                : <FlatList
                                    data={this.state.staffLeave}
                                    renderItem={({ item, index }) =>
                                        this.state.text == null || item.staff_name.toLowerCase().includes(this.state.text.toLowerCase())
                                            ? (this.state.Startdate == null || Moment(Moment(item.date_from, "YYYY-MM-DD").startOf('day')).isSameOrAfter(Moment(this.state.Startdate, "YYYY-MM-DD"), 'day')) &&
                                                (this.state.Enddate == null || Moment(Moment(item.date_to, "YYYY-MM-DD").startOf('day')).isBefore(Moment(this.state.Enddate, "YYYY-MM-DD"), 'day'))
                                                ? <TouchableOpacity style={[components.flatview, { marginTop: 5 }]} onPress={() => navigate('LeaveDetailScreen', { id: item.id })}>
                                                    <View style={[components.listContainer]}  >
                                                        <View style={components.cardContainer}>

                                                            <View style={[components.dotContainer]} >
                                                                <View style={[components.flex_row, components.justifyAlignStart, { padding: 5 }]}>
                                                                    <View style={{ width: '75%' }}>
                                                                        {
                                                                            item.staff_name != null
                                                                                ? <Text style={[components.titleTextStyle]}>{item.staff_name}</Text>
                                                                                : null
                                                                        }
                                                                    </View>
                                                                    {
                                                                        item.date_from != null
                                                                            ? <View style={{ width: '25%' }}>
                                                                                <Text style={[components.titleTextStyle, { fontSize: 13 }]}>{Moment(item.date_from).format("D MMM YYYY")}</Text>
                                                                            </View>
                                                                            : null
                                                                    }

                                                                </View>
                                                            </View>

                                                        </View>
                                                    </View>
                                                </TouchableOpacity>
                                                : null
                                            : null

                                    }
                                    keyExtractor={(item, index) => index.toString()}
                                    extraData={this.state}
                                    nestedScrollEnabled={true}
                                />
                        }
{this.state.view\u access==false
? 
:this.state.isLoading
? 

您是否尝试使用WebView而不是文本,例如:

<WebView style={[components.titleTextStyle]} html={item.staff_name}/>


您是否尝试使用WebView而不是文本,例如:

<WebView style={[components.titleTextStyle]} html={item.staff_name}/>


首先,为什么要从api获取整个组件 这不是建议的模式。您不能在react native中呈现html 若将字符串传递给组件,它将仅将其视为字符串,而不是任何组件


您可以从api中获取url、类型等道具,并在react native中呈现组件,所有业务逻辑仅在component only中呈现。

首先,为什么您要从api中获取整个组件 这不是建议的模式。您不能在react native中呈现html 若将字符串传递给组件,它将仅将其视为字符串,而不是任何组件


您可以从api中获取url、类型等道具,并在react native中呈现组件,仅组件中包含所有业务逻辑

从您发布的图片中,staff_name确实包含显示的数据。希望它准确显示什么?给我们一个示例。这是否回答了您的问题?问题在于您的api数据b因为DB中的员工姓名不正确。首先,检查您发布的图片中的API代码。员工姓名确实包含所显示的数据。希望它准确显示什么?给我们一个例子。这是否回答了您的问题?问题出现在您的API数据中,因为DB中的员工姓名不正确。首先,检查您的API代码