首页 > 解决方案 > 在组件样式加载之前,在 React 头盔中加载我的样式文件

问题描述

在我的应用程序 app.js 中,出于某种原因,我在我的反应头盔中加载了引导 CSS,但在加载组件自定义样式之后加载。所以我的一些覆盖样式不起作用。如何在组件之前加载 react-helmet CSS?请帮助我

应用程序.js

import React, { Component, Suspense, lazy } from "react";
import ...mycomponents
class App extends Component {
render() {
<div>
<Helmet>
 <link
  type="text/css"
  rel="stylesheet"
  href="vendors/bootstrap/css/bootstrap.css"/>
</Helmet>
<Switch>
  <Route path="/home">
    <Home {...this.props} />
  </Route>
</Switch>
</div>
}
}

所以需要在加载 home 组件之前加载 bootsrap.css。

标签: javascriptcssreactjsreact-helmetreact-styleguidist

解决方案


推荐阅读