[英]Next.js React app not showing custom component content
I am new to react and I am currently trying out some basic example.我是新来的,我目前正在尝试一些基本的例子。 I have just created a linked index page and an about page.
我刚刚创建了一个链接索引页面和一个关于页面。 I then created a custom App component which should display everything in the container, instead it is just showing the home/about linked buttons and 'Hello next.js' text (it is not showing ('On every Page'). See page layout below
然后我创建了一个自定义 App 组件,它应该显示容器中的所有内容,而不是它只显示主页/关于链接的按钮和“Hello next.js”文本(它没有显示(“在每个页面上”)。参见页面布局以下
On every page *** this is not showing Home page button |在每一页 *** 这不显示主页按钮 | About page button Hello next.js
关于页面按钮 你好 next.js
Can anyone see any errors?任何人都可以看到任何错误吗? I have tried searching but I still can not see where I am going wrong
我试过搜索,但我仍然看不到我哪里出错了
// _app.js
import App, {Container} from 'next/app';
//define the custome App - a class which extends the
default App
class myApp extends App {
return() {
//compent will be the page content
// e.g. index or about
const {Component, pageProps} = this.props;
return (
//container contains page content
<Container>
{/* Content which will be shared */}
<p>On every Page</p>
{/* Component is page e.g. index or about
*/}
<Component {...pageProd}/>
</Container>
);
}
}
export default myApp;
//index.js
import Link from 'next/link'
// Pass this content as 'props' to child components
const Index = props => (
<div>
<Link href="/index">
<button>Home page</button>
</Link>
<Link href="/about">
<button>About page</button>
</Link>
<p>Hello Next.js</p>
</div>
)
export default Index
// about.js
import Link from 'next/link'
// Pass this content as 'props' tp child components
const About = props => (
<div>
<Link href="/">
<button>Home page</button>
</Link>
<Link href="/about">
<button>About page</button>
</Link>
<p>Hello Next.js</p>
</div>
)
export default About
是的..第一个是return
而不是render
我有一个类似的问题,我的问题是缓存,试试这个
rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm run build:tailwind && npm run dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.