【问题标题】:Unable to render Reactjs-boostrap popover无法呈现 React Js-bootstrap 弹出框
【发布时间】:2020-08-11 08:53:45
【问题描述】:

我安装了以下软件包:

npm install --save react-bootstrap bootstrap

我正在尝试使用here 提供的示例添加一个弹出框。

这是确切的代码:

import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import Popover from 'react-bootstrap/Popover';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Button from 'react-bootstrap/Button';


function App() {
  const popover = (
    <Popover id="popover-basic">
      <Popover.Title as="h3">Popover title</Popover.Title>
      <Popover.Content>
        Popover content <strong>some strong content</strong> Normal content again
      </Popover.Content>
    </Popover>
  );
  
 
  return (
    <div className="App">
    <OverlayTrigger trigger="click" placement="right" overlay={popover}>
      <Button variant="success">Click to trigger popover</Button>
    </OverlayTrigger>
    </div>
  );
}

export default App;

但这只是行不通。我在控制台中看不到任何错误。并且弹出窗口根本不渲染。我错过了什么?

【问题讨论】:

标签: react-bootstrap popover


【解决方案1】:

可能你只需要npm install react-bootstrap bootstrap。您建议的文档中也提到了这一点。

来自this的文章,

Before npm 5.0.0, it was necessary to add --save after package name because it 
will save the installed package to package.json file in the dependency section. 
If you are using a recent version of npm save yourself from unnecessary typing 
and use npm install [Package Name] instead of npm install [Package Name] --save 
by default it will add the installed package to the dependency list in the 
package.json file.

【讨论】:

    猜你喜欢
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 2019-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-12
    • 2012-02-05
    相关资源
    最近更新 更多