我正在开发一个名为MoVid的电影租赁项目,该项目位于React和JavaScript中。这是我的代码:
App.js
Range("A1").Copy Range("E5")
Movie.jsx
import React,{ Component } from "react";
import Movies from "./components/movies";
import "./App.css";
function App() {
return (
<main classname="container">
<Movies></Movies>
</main>
);
}
export default App;
fakeGenreService.js
import React,{ Component } from "react";
import { getMovies } from "../services/fakeMovieService";
class Movies extends Component {
state = {};
render() {
return (
<table classname="table">
<thead>
<tr>
<th>Title</th>
<th>Genre</th>
<th>Stock</th>
<th>Rate</th>
</tr>
</thead>
<tbody>
{this.state.movies.map(movie => (
<tr>
<td>{movie.title}</td>
<td>{movie.genre.name}</td>
<td>{movie.numberInStock}</td>
<td>{movie.dailyRentalRate}</td>
</tr>
))}
</tbody>
</table>
);
}
}
export default Movies;
fakeMovieService.js
export const genres = [
{ _id: "5b21ca3eeb7f6fbccd471818",name: "action" },{ _id: "5b21ca3eeb7f6fbccd471814",name: "Comedy" },{ _id: "5b21ca3eeb7f6fbccd471820",name: "Thriller" }
];
export function getGenres() {
return genres.filter(g => g);
}
我看过:
React code throwing “TypeError: this.props.data.map is not a function”
React JS - Uncaught TypeError: this.props.data.map is not a function
但是他们没有帮助。
其他3个代码文件位于here中。 如果您需要更多信息或代码,请询问我!预先感谢!