<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
我正在开发一个 React 应用程序,当我使用外部库时,样式不起作用。结果不如预期。
我正在使用 https://fkhadra.github.io/react-toastify/ (在那里检查结果)
这就是我看到的结果:
安装外部库时我是否遗漏了什么?
最佳答案
您需要导入 css 才能应用样式。示例代码在他们的 github 存储库中: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>
);
}
}
关于css - 外部库的样式不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51975196/