我安装了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" />
);
}
}
当我在容器上调用info()时,会弹出消息,但消息会以页面顶部的纯文本形式显示,而不是以右上角的样式框显示。该信息也永远不会消失。因此,似乎缺少CSS和JavaScript组件。
我做错了什么?为什么在Linux下安装fsevents时会有那些警告?如果有问题,我正在使用 react 15。我降级为react-toastr 2.9.5版,但没有什么不同。
$ npm install --save react-toastr
[email protected] /home/myApp
└─┬ [email protected]
└─┬ [email protected]
├── [email protected]
└── [email protected]
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 [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/react-scripts/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
最佳答案
您需要添加 CSS
file的 toastr
Running example
关于reactjs - 如何安装React-Toastr,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48651701/