Я работаю над приложением реакции с шаблоном bootstrap. Пока все мои страницы работают хорошо, кроме одной. Когда я нажимаю ссылку на эту страницу, шаблон загружается нормально, когда я обновляю sh на этой странице, я теряю свой стиль bootstrap.
Единственное, что отличает эту страницу от других - это показать страницу, которая использует идентификатор из URL-адреса. Я не уверен, причина проблемы в реакции или в bootstrap. Я новичок в реакции, поэтому предполагаю, что именно так я визуализирую страницу шоу.
показать URL-адрес страницы, передан идентификатор: http://localhost: 3000 / Employee / 1
Шоу код страницы:
import React, { Component } from 'react'
export default class EmpoyeeShow extends Component {
constructor() {
super();
this.state = {
employees: [],
employee: {},
};
}
componentDidMount() {
const id = this.props.match.params.userId;
console.log("this.props.match.params.userId", this.props.match.params.userId)
console.log("params", id)
this.fetchEmployee(id)
}
fetchEmployee = async (id) => {
console.log("id", id)
const response = await fetch(`/employees/`+ id)
const initialUser = await response.json()
const employees = initialUser
this.setState({ employees })
console.log("Employee", this.state.employees[0])
const employee = this.state.employees[0]
this.setState({employee: employee})
}
render() {
const banner = {
background:`url(../assets/images/bg/04.jpg)`,
backgroundSize: 'cover',
backgroundPosition: 'center'}
const breadcrumb = {
background: 'transparent'
}
return (
<>
<div class="innerpage-banner center bg-overlay-dark-7 py-7" style={banner}>
<div class="container">
<div class="row all-text-white">
<div class="col-md-12 align-self-center">
<h1 class="innerpage-title">{this.state.employee.first_name}</h1>
<h6 class="subtitle">{this.state.employee.title}</h6>
<nav aria-label="breadcrumb">
<ol class="breadcrumb" style={breadcrumb}>
<li class="breadcrumb-item active"><a href={this.state.employee.cv} target="_blank"><i class="ti-home"></i> CV</a></li>
<li class="breadcrumb-item active"><a href={this.state.employee.publications} target="_blank"><i class="ti-home"></i> Publications</a></li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<section>
<div class="container">
<div class="row">
<div class="col-md-12 col-lg-6 align-self-center ">
<div class="title text-left">
<h2>About {this.state.employee.first_name}</h2>
<p class="p-0 mb-0">{this.state.employee.description} </p>
</div>
</div>
<div class="col-md-10 col-lg-6 mx-md-auto align-self-center ">
<img class="img-fluid w-100" src={this.state.employee.photo} alt=""/>
</div>
</div>
</div>
</section>
</>
);
}
}
Вот шаблон рабочий:
Not working: введите описание изображения здесь