【发布时间】:2022-02-10 20:07:37
【问题描述】:
众所周知,Next JS 没有任何路由,我正在尝试在 next JS 中构建一个 Web 应用程序,在该应用程序中,我必须对多个路由使用相同的组件,而无需复制粘贴到不同的目录。
目录结构:
src
pages
new (AddListComponent)
edit-[id] (AddListComponent)
添加列表组件
import React from 'react'
import { withRouter } from 'next/router'
class Listing extends React.Component {
constructor(props){
super(props)
this.state = {
}
}
render () {
return (
<div>This is my new component</div>
)
}
}
export default withRouter(Listing)
【问题讨论】:
标签: javascript reactjs next.js