小编UI *_*per的帖子

如何在反应本机导航中使用route.params获取路线参数?

我正在使用 React Native 和 React Native 导航。当我尝试访问 Route.params 时,它说它是一个未定义的对象。我可以使用 this.props.navigation.navigate 方法导航到 PokeDetails 屏幕,但我无法从 route.params.etc 获取参数......请参阅下面的代码。谢谢!

//Home.js

import React, { useState } from "react";
import { View, Text , Button, FlatList, ActivityIndicator, TouchableOpacity, Image } from "react-native";
import { GlobalStyles } from "../styles/GlobalStyles";
import PokeDetails from "./PokeDetails";



class Home extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            isLoading: true,
            dataSource: [],
        }
    }

    componentDidMount() {
        fetch(`https://pokeapi.co/api/v2/pokemon/?limit=20`)
            .then((res)=> res.json())
            .then((response)=> {
                this.setState({
                    isLoading: false,
                    dataSource: response.results,
                })
                console.log("RESPONSE",response)
                console.log("RESPONSE.RESSSULTS",response.results)
            })

    } …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-navigation react-navigation-drawer react-navigation-v5

2
推荐指数
1
解决办法
9211
查看次数

如何在使用 contentContainerStyle 等反应本机平面列表中使用 justifyContent 和alignItems

我正在使用本机反应。现在,当我尝试将平面列表置于屏幕中央,并专门为平面列表提供 justifyContent 和alignItems 时,它给了我一个奇怪的动作。另外,以 justifyContent 和alignItems 为中心的contentContainerStyle 也给出了一个奇怪的动作。昨天一整天都在寻找解决方案。我将在下面提供代码和图像。谢谢。

我试图在中心对齐这个平面列表,就像 justfyContent 和alignItems 会做的那样。您可以看到内容向屏幕左侧倾斜。

在此输入图像描述

import React, { useState } from "react";
import { View, Text , Button, FlatList, ActivityIndicator, TouchableOpacity } from "react-native";
import { GlobalStyles } from "../styles/GlobalStyles";
import PokeDetails from "./PokeDetails";
import SearchBarComponent from "../components/SearchBar";
import PokeBanner from "../components/PokeBanner";

class Home extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            isLoading: true,
            dataSource: [],
        }
    }

    componentDidMount() {
        fetch(`https://pokeapi.co/api/v2/pokemon/?limit=27`)
            .then((res)=> res.json())
            .then((response)=> {
                this.setState({
                    isLoading: false,
                    dataSource: response.results,
                })
                console.log("RESPONSE",response) …
Run Code Online (Sandbox Code Playgroud)

javascript user-interface reactjs react-native react-native-flatlist

1
推荐指数
1
解决办法
5505
查看次数

如何使用 Angular 的 *ngFor 内联显示项目

我正在尝试内联显示项目而不是出现在不同的行中。请看下面的代码和图片。我尝试在网上寻找解决方案,但其他人都在询问不同的用例。请告诉我。谢谢!

在此输入图像描述

<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Document</title>
 </head>
 <body>
    <div>
        <div class="pimg1">
           <div class="ptext">
               <span class="borderStyle">
                   Kenny's Site
               </span>
           </div>
        </div>
        <section class="section section-light">
            <h2>Skills</h2>
            <p class="skills" *ngFor="let skill of skills">{{skill.skill}}</p>
        </section>
        <div class="pimg2">
           <div class="ptext">
               <span class="borderStyle">
                   Image2 Text
               </span>
           </div>
        </div>
        <section class="section section-dark">
           <h2>Section 1</h2>
           <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolores, saepe.</p>
       </section>
       <div class="pimg3">
           <div class="ptext">
               <span class="borderStyle">
                   Image3 Text
               </span>
           </div>
        </div>
        <section class="section section-dark">
           <h2>Section …
Run Code Online (Sandbox Code Playgroud)

javascript css arrays ngfor angular

1
推荐指数
1
解决办法
2299
查看次数