首页 > 解决方案 > 使用 @Storybook/addon-docs 显示模板的代码

问题描述

我在 Storybook 中记录我的组件。我添加@storybook/addon-docs并在 *.stories.ts 中定义了这样的故事:

export const Button = () => ({
  template: '<button class="button">Delete</button>',
});

带有样式的按钮显示正确,但是当有人单击“显示代码”时,它会显示故事的代码,而不仅仅是模板。

() => ({
  template: '<button class="button button-danger">Delete</button>'
})

是否可以配置“显示代码”显示模板,而不是整个故事?

标签: angularstorybookangular-storybook

解决方案


尝试评论,文档来源

//Connect below line from .stories.js
parameters: {
 docs: {
  source: {
    type: 'code'
  }
 }
}

推荐阅读