如何安装React-Toastr

mes*_*ssy 5 toastr reactjs

我安装了react-toastr并集成了示例代码。

import React from 'react'
import { ToastContainer } from 'react-toastr';
class Notifier extends React.Component
{
  updateNotify()
  {
    this.refs.container.info('hola el mundo');
  }
  render()
  {
    return(
      <ToastContainer ref="container"
      className="toast-top-right" />
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

当我在容器上调用info()时,消息会弹出,但就像页面顶部的纯文本一样,而不是右上角的样式框。该消息也永远不会消失。因此,似乎缺少CSS和JavaScript组件。

我做错什么了?为什么在Linux下安装fsevents时会有那些警告?如果有问题,我正在使用反应15。我降级为react-toastr 2.9.5版,但没有什么不同。

$ npm install --save react-toastr
myApp@0.3.1 /home/myApp
??? react-toastr@3.0.0
  ??? babel-runtime@6.26.0
    ??? core-js@2.5.3
    ??? regenerator-runtime@0.11.1

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.0.17 (node_modules/react-scripts/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Run Code Online (Sandbox Code Playgroud)

Sag*_*b.g 3

您需要添加以下CSS文件toastr

运行示例

  • 在 `node_modules/react-toastr/src/docs/configuration.md` 中,您将找到所需 css 的引用。 (2认同)