简体   繁体   English

React Bootstrap 组件在我的 App.js 中加载时没有出现

[英]React Bootstrap component doesn't appear when I load it in my App.js

I've created a react component called ImagePost and when I call it in my App.js it doesn't appear.我创建了一个名为 ImagePost 的反应组件,当我在 App.js 中调用它时它不会出现。

import Container from 'react-bootstrap/Container';
import Image from 'react-bootstrap/Image'
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';

const ImagePost = () => {
  return (
    <div>
      <Container fluid>
        <Row>
          <Col xs={6} md={4}>
            <Image className='fluid' src={require('../Images/lonepeak.jpg')} responsive/>
          </Col>
        </Row>
      </Container>
    </div>
  )
}

export default ImagePost

Files文件

Try updating your relative path for the image source to:尝试将图像源的相对路径更新为:

src={require("./../Images/lonepeak.jpg")}

Alternatively import your image same as you would any other resource/package:或者像导入任何其他资源/包一样导入您的图像:

import lonepeak from "./../Images/lonepeak.jpg";

and use it like this:并像这样使用它:

src={lonepeak} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将反应组件导入我的app.js - Unable to import react component to my app.js CoreUI 图标没有出现在我的反应 js 应用程序中 - CoreUI Icon doesn't appear in my react js app Coursera-学习Angular-为什么我的app.js无法加载? - Coursera - Learn Angular - Why can't I get my app.js load? 为什么在 class 组件的 state 中使用 props 时,在 App.js 中更改组件 props 不会在浏览器中自动刷新它? - Why does changing Component props in App.js doesn't automatically refreshes it in browser when props are used in state of class component? 装入组件时不加载导入的脚本-React JS - Imported Script doesn't load when a component is mounted - React JS React js,为什么在更改open的值时我的组件不重新渲染? - React js, why doesn't my component re-render when I change the value of open? 无法加载从 React/redux 中的另一个 js 文件导入的 App.js 中的函数 - can't load a function In App.js imported from another js file in React/redux 我如何使用post将React组件从server.js渲染到App.js? - How can I render a React component from server.js to App.js using post? React JS如何显示组件onclick,但不在App.js中 - React JS How to display component onclick, but not in App.js 当我尝试在我的 react.js 组件中迭代对象数组时,为什么会出现错误? - Why does error appear when I try to iterate array of objects in my react.js component?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM