外部库的样式不起作用?
Style of external libraries doesn't work?
我正在开发一个 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>
);
}
}
我正在开发一个 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>
);
}
}