You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js 13中<Link>标签无法使用,是否需要额外配置?

解决Next.js 13中Link标签运行时错误的问题

问题根源

在你用--experimental-app启用的Next.js 13 App Router模式下,组件导入规则和旧版Pages Router不同:

  • <Link>组件需要从next/navigation导入,而非旧版的next/link
  • <Image>组件必须从next/image导入,且必须提供src属性(你的代码中<Image>缺少这个必填属性)

你没有添加这两个组件的导入语句,导致运行时无法找到组件的内部方法,触发Cannot read properties of undefined (reading 'call')错误。

修复方案

  1. 在组件文件顶部添加正确的导入语句:
import Link from 'next/navigation';
import Image from 'next/image';
  1. 给<Image>组件补充必填的src属性,同时建议设置width和height(或使用fill属性配合父容器实现响应式布局)

修复后完整代码示例

import Link from 'next/navigation';
import Image from 'next/image';

export default function Home() {
  return (
    <>
      <h1 className='text-3xl font-bold underline'>
        Hello my friends
      </h1>

      <Link href='/'>Click Me</Link>
      <Image 
        alt='图片描述文本' 
        src='/your-image-file.jpg' // 替换为实际图片路径
        width={200} 
        height={200} 
      />
    </>
  )
}

内容的提问来源于stack exchange,提问作者Mehmet Wesim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 01:01:22