Reactjs 财产';args';类型上不存在(args:Props)
我无法理解为什么收到此错误Reactjs 财产';args';类型上不存在(args:Props),reactjs,typescript,storybook,Reactjs,Typescript,Storybook,我无法理解为什么收到此错误类型(args:Props)=>元素上不存在属性“args” 我正在尝试将参数添加到我的故事书组件中。这就是我的.stories.tsx文件的外观 import React from "react"; import { Story, Meta } from "@storybook/react"; import { Props, Button } from "."; export default { ti
类型(args:Props)=>元素上不存在属性“args”
我正在尝试将参数添加到我的故事书组件中。这就是我的.stories.tsx
文件的外观
import React from "react";
import { Story, Meta } from "@storybook/react";
import { Props, Button } from ".";
export default {
title: "General/Button",
component: Button
} as Meta;
const Template = (args: Props) => <Button {...args} />;
export const PrimaryA = Template.bind({});
PrimaryA.args = { <-- ERROR
variant: "primary"
};
如何查看界面道具中已有.args
属性。我不知道如何修理它。谢谢:))
编辑
我编辑了界面
export interface Props {
variant: string;
children?: React.ReactNode;
}
以及PrimaryA
对象
const Template = (props: Props) => <Button {...props} />;
export const PrimaryA = Template({
variant: "disabled"
});
const模板=(道具:道具)=>;
导出常量PrimaryA=模板({
变体:“残疾”
});
还是什么都没有。我在故事书中看不到组件,您需要使用Typescript版本,它是docs now()中的一个选项,但相关代码如下所示:
从“@storybook/react”导入{Meta,Story}”;
导出默认值{
标题:“按钮”,
组件:按钮,
}作为元;
//Args是箭头函数“Template”的参数,但不是元素的属性,因此错误为correctUse PrimaryA=Template(Args);相反,Button
as元素还接收argsButton(props:props)
Button接收args作为其props的属性(在props界面中定义)。这并不意味着args是ButtonIt的一个属性,它仍然不起作用
const Template = (props: Props) => <Button {...props} />;
export const PrimaryA = Template({
variant: "disabled"
});