我试图在hosted url (部署我的构建的地方).but基础上发送一些文本,我得到的是错误ReferenceError:位置未定义--是我的代码
https://codesandbox.io/s/laughing-mendel-pf54l?file=/pages/index.js
export const getStaticProps = async ({ preview = false, previewData = {} }) => {
return {
revalidate: 200,
props: {
//req.host
name: location.hostname == "www.google.com" ? "Hello" : "ccccc"
}
};
};发布于 2021-05-24 10:38:24
您能显示您的导入吗?因为它可能是从'next/client'导入路由器。
假设您正在使用基于功能的组件。
您需要按以下方式导入路由器:
import {useRouter} from "next/router";在你的身体中:
const router = useRouter();https://stackoverflow.com/questions/65819812
复制相似问题