我试着从JSX页面转到HTML页面,但是当我尝试这样做的时候,我总是得到一个错误。总是一个404页面说它不存在。就好像它不存在,尽管我清楚地把它放在我的文件和同一个目录中。
games.jsx
import React from "react";
import { useEffect, useState } from "react";
import moment from 'moment';
import Link from 'next/link';
export default function Home() {
const[dataResponse, setdataResponse] = useState([]);
useEffect(() => {
async function getPageData() {
const apiUrlEndpoint = 'http://localhost:3000/api/games';
const response = await fetch(apiUrlEndpoint);
const res = await response.json();
console.log(res.games);
setdataResponse(res.games);
}
getPageData();
}, []);
return (
<div className='bg-gray-100 min-h-screen'>
<a href="newgame.html">Click to Add New Game Product.</a>
{dataResponse.map((games) => {
var d = new Date(games.DateWhenAdded);
var now = moment(d).format('l');
return (
<div key= {games.ProductID}>
<div>{games.ProductName}</div>
<div>
<img src={games.ProductImage} width="400" height="400" alt=""/>
</div>
<div>
{games.ProductDescription}
</div>
<div>
Product added on: {now}
</div>
<div>
Product price: ${games.ProductPrice}
</div>
</div>
)
})}
</div>
);
}
这是我想重定向到的表单。它叫做“newgame.html”
<!DOCTYPE html>
<html lang = "en">
<head>
<title>
New Game Addition
</title>
</head>
<body>
<form method="post" action="dbcon.php">
<input type="number" name="ProductID" placeholder="Product ID">
<input type="text" name="ProductName" placeholder="Name of Product.">
<input type="text" name="ProductDescription" placeholder="Describe the Product.">
<input type="file" name="ProductImage" placeholder="Put in Image">
<input type="date" name="DateWhenAdded" placeholder="01/01/2001">
<input type="submit" name="submit" value="SUBMIT">
</form>
</body>
</html>
如果你能给予我一些建议,我应该尝试什么,这将是非常感谢。谢谢。
1条答案
按热度按时间dluptydi1#
将
newgame.html
文件放入您的public folder...此文件夹对于
robots.txt
、favicon.ico
、Google站点验证和任何其他静态文件(包括.html
)也很有用!并使用以下命令
请注意,URL以
/
开头。