mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 08:01:20 +08:00
knobs addon Vue.js example
This commit is contained in:
parent
276b114901
commit
317a4e1994
@ -55,6 +55,39 @@ stories.add('as dynamic variables', () => {
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### With Vue.js
|
||||||
|
```js
|
||||||
|
import { storiesOf } from '@storybook/vue';
|
||||||
|
import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';
|
||||||
|
|
||||||
|
import MyButton from './Button.vue';
|
||||||
|
|
||||||
|
const stories = storiesOf('Storybook Knobs', module);
|
||||||
|
|
||||||
|
// Add the `withKnobs` decorator to add knobs support to your stories.
|
||||||
|
// You can also configure `withKnobs` as a global decorator.
|
||||||
|
stories.addDecorator(withKnobs);
|
||||||
|
|
||||||
|
// Knobs for Vue props
|
||||||
|
// Knobs for Vue props
|
||||||
|
stories.add('with a button', () => ({
|
||||||
|
components: { MyButton },
|
||||||
|
template:
|
||||||
|
`<button disabled="${boolean('Disabled', false)}" >
|
||||||
|
${text('Label', 'Hello Storybook')}
|
||||||
|
</button>`
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Knobs as dynamic variables.
|
||||||
|
stories.add('as dynamic variables', () => {
|
||||||
|
const name = text('Name', 'Arunoda Susiripala');
|
||||||
|
const age = number('Age', 89);
|
||||||
|
|
||||||
|
const content = `I am ${name} and I'm ${age} years old.`;
|
||||||
|
return `<div>${content}</div>`;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### With Angular
|
### With Angular
|
||||||
```js
|
```js
|
||||||
import { storiesOf } from '@storybook/angular';
|
import { storiesOf } from '@storybook/angular';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user