我正在开发一个反应应用程序,当我使用外部库时,样式不起作用。结果不如预期。
我正在使用https://fkhadra.github.io/react-toastify/(检查那里的结果)
这就是我看到结果的方式:
安装外部库时是否有一些我缺少的东西?
您需要导入css才能应用样式。示例代码在他们的github repo:https://github.com/fkhadra/react-toastify中
import React, { Component } from 'react';
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
// minified version is also included
// import 'react-toastify/dist/ReactToastify.min.css';
class App extends Component {
notify = () => toast("Wow so easy !");
render(){
return (
<div>
<button onClick={this.notify}>Notify !</button>
<ToastContainer />
</div>
);
}
}