diff --git a/addons/docs/src/frameworks/vue/extractArgTypes.ts b/addons/docs/src/frameworks/vue/extractArgTypes.ts index ca65e50f1e3e..6a0fc052335d 100644 --- a/addons/docs/src/frameworks/vue/extractArgTypes.ts +++ b/addons/docs/src/frameworks/vue/extractArgTypes.ts @@ -17,10 +17,17 @@ export const extractArgTypes: ArgTypesExtractor = (component) => { props.forEach(({ propDef, docgenInfo, jsDocTags }) => { const { name, type, description, defaultValue: defaultSummary, required } = propDef; const sbType = section === 'props' ? convert(docgenInfo) : { name: 'void' }; - let defaultValue = defaultSummary && (defaultSummary.detail || defaultSummary.summary); + let defaultValue: any = defaultSummary && (defaultSummary.detail || defaultSummary.summary); try { // eslint-disable-next-line no-eval defaultValue = eval(defaultValue); + // B/c Vue requires that Object/Array defaults be supplied as factory functions. + if ( + typeof defaultValue === 'function' && + ['object', 'array', 'other'].includes(sbType.name) + ) { + defaultValue = defaultValue(); + } // eslint-disable-next-line no-empty } catch {} diff --git a/examples/vue-kitchen-sink/src/stories/Button.vue b/examples/vue-kitchen-sink/src/stories/Button.vue index 4a20dfb5f9ac..67fecf7c8a55 100644 --- a/examples/vue-kitchen-sink/src/stories/Button.vue +++ b/examples/vue-kitchen-sink/src/stories/Button.vue @@ -2,7 +2,7 @@