描述bug
我的一些组件可以接受不同类型的props,例如String或Number,但是当涉及到Storybook时,它将输入渲染为对象。我不确定这是否是一个bug,或者它应该表现得像那样,但如果有可能选择props中指定的类型之一并为此类型渲染输入字段,那就太好了。
重现
- component.vue*
<template>
<element :height=""height" :width="width" />
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend( {
name: 'component',
props: {
'width':{
type: [String, Number],
default: undefined,
},
'height':{
type: [String, Number],
default: undefined
},
},
)
</script>
- component.stories.js*
import component from "../components/component.vue";
export default {
title: "Component",
component: component,
};
export const Component = (args, { argTypes }) => ({
components: {
component,
},
props: Object.keys(argTypes),
template: '<component v-bind="$props" />',
});
1条答案
按热度按时间nmpmafwu1#
嘿,@vitalii-bulyzhyn,我不确定这是否是vue-docgen-api(从参数中推断类型的底层机制)的错误,但你可以手动指定参数的类型,可能解决你的问题:
https://storybook.js.org/docs/vue/api/argtypes#manual-specification