Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 财产';args';类型上不存在(args:Props)_Reactjs_Typescript_Storybook - Fatal编程技术网

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元素还接收args
Button(props:props)
Button接收args作为其props的属性(在props界面中定义)。这并不意味着args是ButtonIt的一个属性,它仍然不起作用
const Template = (props: Props) => <Button {...props} />;

export const PrimaryA = Template({
  variant: "disabled"
});