我正在 nextjs 工作,我正在尝试制作“动态路由”,我希望点击后我的网址应该像“myurl.com/article/55”
为此,我使用以下“链接标签”
<Link href={{pathname: "article/[id]",query: { id: post.id },}}>
<a className="rdmre-btn"> Read More</a>
</Link>
Run Code Online (Sandbox Code Playgroud)
这是我在文件(“pages/article/[slug].js)”中的代码,我错在哪里?我希望每当我单击任何博客时,博客详细信息页面都应该打开。
import Axios from "axios";
import { useRouter } from "next/router";
import Link from "next/link";
import LatestBlogs from "../../components/LatestBlogs/LatestBlogs";
const Post = ({ post }) => {
const router = useRouter();
const htmlString = post.description_front;
if (router.isFallback) {
return <div>Loading...</div>;
}
return (
<>
<header className="bgbanner blog_header">
<div className="container cont">
<div className="header">
</div>
</div>
<div className="container "></div>
</header>
<section>
<div className="container Blog_page_sidebar">
<div className="blog_details"> …Run Code Online (Sandbox Code Playgroud) 我正在使用与scala的playframework,我正在尝试构建表单,但得到以下错误
"找不到隐式的MessagesProvider实例.请参阅https://www.playframework.com/documentation/2.6.x/ScalaForms#Passing-MessagesProvider-to-Form-Helpers "这里是我的index.scala.html
@(customerForm:Form[Customer])
@import helper._
@main("welcome") {
<h1>Customer Form</h1>
@form(action=routes.Application.createCustomer()) {
@inputText(customerForm("Credit Limit"))
@inputText(customerForm("Customer Name"))
<input type="submit" value="Submit">
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序控制器代码
package controllers
import play.api._
import play.api.mvc._
import models.Customer
import play.api.data._
import play.api.data.Forms._
class Application extends Controller {
def customerForm = Form(mapping("Customer Name" -> nonEmptyText,
"Credit Limit" -> number)(Customer.apply)(Customer.unapply))
def index = Action { implicit request =>
Ok(views.html.index(customerForm))
}
def createCustomer = Action { implicit request =>
customerForm.bindFromRequest().fold(
formWithErrors => BadRequest(views.html.index(formWithErrors)),
customer => Ok(s"Customer ${customer.name} created successfully"))
} …Run Code Online (Sandbox Code Playgroud)