外部库的风格不起作用? [关闭]

问题描述 投票:0回答:1

我正在开发一个反应应用程序,当我使用外部库时,样式不起作用。结果不如预期。

我正在使用https://fkhadra.github.io/react-toastify/(检查那里的结果)

这就是我看到结果的方式:

enter image description here

安装外部库时是否有一些我缺少的东西?

css reactjs notifications styles toast
1个回答
1
投票

您需要导入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>
          );
        }

  }
© www.soinside.com 2019 - 2024. All rights reserved.