3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vueのstorybookにobjectのpropsを入れるメモ

Posted at

よく見るやつ


import { storiesOf } from '@storybook/vue'
import ItemComponent from './ItemComponent.vue'

storiesOf('ItemComponent', module).add('default', () => {
  const title = 'test'
  return {
    components: { ItemComponent },
    template: `
      <item-component title='${title}' />`
  }
})

いや、そうじゃないんだよな…
Objectとか型付けたデータを渡したい…

…よく見たらこれ、.vueの中身を返してるだけじゃね?


import { storiesOf } from '@storybook/vue'
import ItemComponent from './ItemComponent.vue'
import Item from '@/types/Item'

storiesOf('ItemComponent', module).add('default', () => {
  const item: Item = {
    id: 'ddd',
    title: 'test',
    body: 'test'
  }
  return {
    components: { ItemComponent },
    data: () => {
      return {
        item
      }
    },
    template: `
      <item-component :item='item' />`
  }
})

こうじゃ!!!!!!!!!

めでたしめでたし。

3
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?