ReactJS bootstrap carousel组件Map不工作

vmpqdwk3  于 2023-04-20  发布在  React
关注(0)|答案(1)|浏览(120)

我正在做一个项目,应该有两个不同的网页和移动的布局.对于网页,我想在一个网格MUI卡,而在移动,我想一个引导转盘.我目前正在尝试这个:

import React from "react";

import { projects } from "../data";
import ScreenDetection from "../tools/screenDetection";

import "animate.css/animate.min.css";

import { DesktopComputerIcon } from "@heroicons/react/solid";
import { AnimationOnScroll } from 'react-animation-on-scroll';
import Card from '@mui/material/Card';
import CardMedia from '@mui/material/CardMedia';
import { CardActionArea } from '@mui/material';
import { Carousel } from 'react-bootstrap';

export default function Projects() {

  let projectList;

  if (ScreenDetection() === false) {
    projectList =
      <div className="grid grid-cols-2 gap-6">
        {projects.map((project) => (
          <Card sx={{ width: 1, height: 250 }}>
            <CardActionArea>
              <CardMedia
                sx={{ 
                  height: 250,
                  ':hover': {
                    borderRadius: "20px", // theme.shadows[20]
                  },
                }}
                image={project.image}
                title="green iguana"
              />
            </CardActionArea>
          </Card>
        ))}
      </div>
  } else {
    console.log("MOBILE HERE")
    projectList = 
      <div>
        <Carousel>
          {projects.map(project => (
            <Carousel.Item>
              <img
                className="d-block w-100"
                src={project.image}
                alt={project.title}
              />
              <Carousel.Caption>
                <h3>{project.title}</h3>
                <p>{project.subtitle}</p>
              </Carousel.Caption>
            </Carousel.Item>
          ))}
        </Carousel> 
      </div>       
  }
  return (
    ...
  )

在返回函数中引用它:

<div>
          {projectList}
        </div>

但结果似乎是这样的

你知道为什么会这样吗?谢谢!

wz3gfoph

wz3gfoph1#

实际上我刚意识到我需要加上

import 'bootstrap/dist/css/bootstrap.min.css';

然而,它弄乱了我的TailwindCSS样式。我想知道最好的解决方法是什么。

相关问题