如何将背景颜色传递给@storybook中的vue组件
// SomeComponent.stories.js
const defaultArgs = {
theme: 'light'
};
export default {
title: 'SomeComponent',
component: SomeComponent,
args: defaultArgs,
};
// Define template for SomeComponent Story
const SomeComponentTemplate = (args, { argTypes }) => ({
components: { SomeComponent },
props: Object.keys(argTypes),
template: `
<SomeComponent :theme="theme"/>
`
});
export const Default = SomeComponentTemplate.bind({});
Default.args = { ...defaultArgs };
每当我通过 @storybook/addon-backgrounds
我想将值传递给我的组件。
假设,如果用户从背景中选择 black
,我想将 black
传递给 theme
属性。
可以这样做吗?
// SomeComponent.stories.js
const defaultArgs = {
theme: 'light'
};
export default {
title: 'SomeComponent',
component: SomeComponent,
args: defaultArgs,
};
// Define template for SomeComponent Story
const SomeComponentTemplate = (args, { argTypes }) => ({
components: { SomeComponent },
props: Object.keys(argTypes),
template: `
<SomeComponent :theme="theme"/>
`
});
export const Default = SomeComponentTemplate.bind({});
Default.args = { ...defaultArgs };
Whenever I change the background color from storybook via @storybook/addon-backgrounds
I would want to pass the value to my component.
Say, If user selects black
from the Background, I want to pass black
to the theme
property.
Is it possible to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论