Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.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
Javascript 在故事书中隐藏每个故事的插件_Javascript_Reactjs_Storybook - Fatal编程技术网

Javascript 在故事书中隐藏每个故事的插件

Javascript 在故事书中隐藏每个故事的插件,javascript,reactjs,storybook,Javascript,Reactjs,Storybook,我正在使用带有React的Storybook构建一个组件库。 使用CSF方法包含故事 我有多个插件,在显示单个故事时使用它们。 我还在一个视图中同时显示所有故事,作为参考——我想禁用特定插件的正是这个故事。在这种情况下,我想禁用旋钮 当我尝试禁用每个故事的单个插件时,什么都没有发生 我在下面包含了我的stories.js文件的简化版本: import React from 'react'; import Button from './button'; import { withKnobs, te

我正在使用带有React的Storybook构建一个组件库。 使用CSF方法包含故事

我有多个插件,在显示单个故事时使用它们。 我还在一个视图中同时显示所有故事,作为参考——我想禁用特定插件的正是这个故事。在这种情况下,我想禁用旋钮

当我尝试禁用每个故事的单个插件时,什么都没有发生

我在下面包含了我的
stories.js
文件的简化版本:

import React from 'react';
import Button from './button';
import { withKnobs, text } from '@storybook/addon-knobs/react';

// global settings to be exported 
export default {
  title: 'components/Buttons',
  component: Button,
  decorators: [withKnobs],
  parameters: { options: {showPanel: true }}
}

// define individual stories
const Basic = () => <Button className={text("ClassName-Basic", "button basic")} id={text("ID", "Hello-id-basic")} content={text('Content', 'some text for Basic button here')}/>;
const Primary = () => <Button className={text("ClassName-Primary", "button primary")} id={text("ID", "Hello-id-primary")} content={text('Content', 'some text for Primary button here')}/>;
const Secondary = () => <Button className={text("ClassName-Secondary", "button secondary")} id={text("ID", "Hello-id-secondary")} content={text('Content', 'some text for Secondary button here')}/>;
const Disabled = () => <Button className={text("ClassName-Disabled", "button disabled")} id={text("ID", "Hello-id-disabled")} content={text('Content', 'some text for Disabled button here')}/>;
// define all stories together to be displayed in one view
const All = () => <div><Basic /><br /><Primary /><br /><Secondary /><br /><Disabled /></div>;

// export all components individually, and then export them all together
export  {Basic, Primary, Secondary, Disabled, All};

// settings for the 'All' story
All.story = {
  parameters: { 
    options: { 
      withKnobs: {
        disable: true, // do not show the knobs addon on this story
      } 
    }
  }
};

从“React”导入React;
从“./按钮”导入按钮;
从“@storybook/addonknobs/react”导入{withKnobs,text}”;
//要导出的全局设置
导出默认值{
标题:“组件/按钮”,
组件:按钮,
装饰师:[带旋钮],
参数:{options:{showPanel:true}}
}
//定义个别故事
常量基本=()=>;
常量Primary=()=>;
const Secondary=()=>;
常数禁用=()=>;
//一起定义要在一个视图中显示的所有故事
常量All=()=>


; //单独导出所有零部件,然后一起导出 导出{Basic、Primary、Secondary、Disabled、All}; //“全部”故事的设置 All.story={ 参数:{ 选项:{ 带旋钮:{ disable:true,//不显示此故事中的旋钮插件 } } } };
尽管添加了此设置以禁用“全故事”视图上的旋钮,但它仍然显示。 我做错了什么


我使用的是故事书版本5.2.8

Nevermind,只需将
disable:true
更改为
disabled:true
以下是隐藏控件的方法:
parameters:{controls:{disabled:true}
还可以隐藏插件面板:
参数:{options:{showPanel:false}}
如果要隐藏所有故事的插件面板,请在/.storybook/preview.js中的参数变量中写入
选项:{showPanel:false}