Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue use 'addon-knobs' throw Error #2949

Closed
iswear1987 opened this issue Feb 9, 2018 · 2 comments
Closed

Vue use 'addon-knobs' throw Error #2949

iswear1987 opened this issue Feb 9, 2018 · 2 comments

Comments

@iswear1987
Copy link

iswear1987 commented Feb 9, 2018

Issue details

I just want add @storybook/addon-knobs/vue to storybook, but it not work, could you tell me how to use 'addon-knobs' for vue components please,thanks

It throw

Uncaught TypeError: Cannot read property 'emit' of undefined
at KnobManager.js:92

Steps to reproduce

// .storybook/addons.js

import '@storybook/addon-actions/register';
import '@storybook/addon-notes/register';
import '@storybook/addon-knobs/register';
// src/stories/index.js

import {storiesOf} from '@storybook/vue';
import { withKnobs, number } from '@storybook/addon-knobs/vue';
// ...
const stories = storiesOf('Storybook Knobs', module);
stories.addDecorator(withKnobs);
// ...
storiesOf('path/to/Component', module)
    .add('componentName', () => {
        const highlightTagId = number('highlightTagId', 64)
        // ...
    })

Storybook and other modules version

  • @storybook/vue@3.3.12
  • @storybook/addons@3.3.12
  • vue@2.5.13

Affected platforms

  • OS: fedora 27
  • Browser: chrome 64.0.3282.140 (64bit)

Screenshots

image

image

image

@Flui
Copy link

Flui commented Feb 16, 2018

Here you created two stories. But you missed to add the Knobs decorator to the second story.

// src/stories/index.js

import {storiesOf} from '@storybook/vue';
import { withKnobs, number } from '@storybook/addon-knobs/vue';
// ...
// first story (this is an empty story)
const stories = storiesOf('Storybook Knobs', module);
stories.addDecorator(withKnobs);
// ...
// second story
storiesOf('path/to/Component', module)
    .addDecorator(withKnobs) // TODO: this line should fix your error
    .add('componentName', () => {
        const highlightTagId = number('highlightTagId', 64)
        // ...
    })

@iswear1987
Copy link
Author

@Flui thanks Flui, that did it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants