React.js-通过卡片引导程序进行迭代

时间:2020-02-26 11:34:16

标签: javascript html arrays reactjs react-bootstrap

我对React.js还是很陌生。如果我有一组图像,这些图像是连续3张卡片,并且在卡片上显示三行,每行之间有空格。 我想知道如何使用下面的卡引导程序代码遍历图像,

function App() {
    return (

        <Card style={ { width: "18rem" } }>
            <Card.Img variant="top" src="holder.js/100px180" />
            <Card.Body>
                <Card.Title>Card Title</Card.Title>
                <Card.Text>
                    Some quick example text to build on the card
                    title and make up the bulk of
                    the card 's content.
                </Card.Text>
            </Card.Body>
        </Card>
    );
}

1 个答案:

答案 0 :(得分:0)

如果您想将多张卡片显示为列表或其他内容,可以考虑遍历数组并按如下所示呈现多张卡片

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace RazorPagesMovie
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}