我有一个注册页面的功能组件.我正在try 为这个组件声明props ,这样我就可以从另一个组件向它传递适当的值.这就是我要做的:
export default function SignupPage({mode = 'patient'} : {mode: 'patient' | 'doctor'}) {
{/* CODE FOR SIGNUP PAGE HERE */}
}
如代码所示,我希望缺省值mode
为patient
.它应该始终是patient
或doctor
中的一个.
当我用npm run dev
运行这段代码时,一切都运行得很好.当我try 使用npm run build
构建时,我收到以下错误:
- info Linting and checking validity of types ...Failed to compile.
app/signup/page.tsx
Type error: Page "app/signup/page.tsx" has an invalid "default" export:
Type "{ mode: "patient" | "doctor"; }" is not valid.
我try 了多种方法,比如宣布interface
分和mode: 'patient' | 'doctor';
分的type
分.它总是给出相同的错误.
如有任何帮助和指导,我们将非常感谢??