You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
meta duplicate
A clear and concise description of what the bug is.
if add in _document.js
just like
// _document is only rendered on the server side and not on the client side
// Event handlers like onClick can"t be added to this file
// ./pages/_document.js
import Document, {Html, Head, Main, NextScript} from "next/document";
import React from "react";
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx);
return {...initialProps};
}
render() {
return (
<Html>
<Head>
<link rel="icon" href="../static/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="../static/favicon.ico" type="image/x-icon"/>
<meta name="viewport" content="width=device-width"/> // bug 在每个页面的 Head 里面加这一行,否则系统会默认加这一行
</Head>
<body>
<Main/>
<NextScript/>
</body>
</Html>
);
}
}
export default MyDocument;
and also add Head tag in page.js, just like
import React from "react";
import Head from "next/head";
import {withRouter} from "next/router";
export default withRouter(class extends React.Component {
constructor(props) {
super(props);
}
render() {
console.log(this.props.router.asPath);
return (
<div>
<Head>
<title>xxxxxx</title>
</Head>
</div>
);
}
});
the result is
nextjs will auto add to page
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Go to '...'
Click on '....'
Scroll down to '....'
See error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
OS: [e.g. macOS, Windows]
Browser (if applies) [e.g. chrome, safari]
Version of Next.js: [e.g. 6.0.2]
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Bug report
meta duplicate
Describe the bug
meta duplicate
A clear and concise description of what the bug is.
if add in _document.js
just like
and also add Head tag in page.js, just like
the result is
nextjs will auto add to page
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: