reactjs - 如何在使用下一个路由器时解决未处理的运行时错误
问题描述
我在使用useRouter
from时遇到以下错误next/router
。
TypeError: Cannot read property 'getBoundingClientRect' of null
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
function ActiveLink({ children, href, activeClassName }) {
const { asPath } = useRouter()
console.log(asPath)
return (
<Link href={href} />
)
}
export default ActiveLink
解决方案
推荐阅读
- git - Git Change Head to certain commit 不会更改文件中的数据
- javascript - 使用 javascript 显示图像的多个下拉菜单
- rest - REST API Google Drive 分段上传(C++ 生成器)
- oracle - 在 sqlplus 中执行脚本时出错,选项不是有效数字
- ios - 为什么有些图像使用 gpuimage 过滤会旋转 90 度?
- python - 访问文件中的第 n 个泡菜
- angular - Angular:急切加载使组件不被渲染
- python - 如何在 Python 3 的 Plotly 中将其悬停在折线图中一次显示数据点及其标签?
- angular - 如何仅从 json 响应中获取一些信息?
- python - Python Flask Server 生成太多新线程